Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set version in __init__.py #11

Open
mrpgraae opened this issue Jun 4, 2021 · 4 comments
Open

Automatically set version in __init__.py #11

mrpgraae opened this issue Jun 4, 2021 · 4 comments

Comments

@mrpgraae
Copy link

mrpgraae commented Jun 4, 2021

First of all, thank you for this @tiangolo, it's a very convenient plugin to have.

If this could somehow be extended to work like Versioneer or Miniver, so that it overrides the __version__ variable in __init__.py to dynamically use the git tag during development and then override that with a static string at build time, it would be absolutely perfect. Basically one would never have to manually set the version in __init__.py, just set the git tag.

If you would be interested in doing this, I wouldn't mind making the PR but I'm not sure about what limitations Poetry plugins have, so don't know if it's even possible.

@mrpgraae
Copy link
Author

mrpgraae commented Jun 4, 2021

Adding to this, it would be awesome to have the same kind of version format as in Versioneer:

A build 5 commits ahead tag 0.20.0, latest commit being abcd123 would be: 0.22.0+5.abcd123

A build 5 commits ahead tag 0.20.0, latest commit being abcd123 and with uncommitted changes would be: 0.22.0+5.abcd123.dirty

@sl304227-nh
Copy link

Another package poetry-dynamic-versioning is considering adding poetry plugin support officially, rather than as a separate package as it currently stands. That package has all of the fancy version numbers that you're looking for @mrpgraae .

Does it make sense to combine our efforts of poetry-version-plugin with poetry-dynamic-versioning? mtkennerly/poetry-dynamic-versioning#39

@mrpgraae
Copy link
Author

mrpgraae commented Aug 21, 2021

@sl304227-nh Thanks, poetry-dynamic-versioning seems somewhat broader in scope than this project, AFAICT it already supports the behavior that I'm looking for, i.e. using the Git tag as the source of truth, then setting init.py version and package version based on that?

I would say that it would definitely make sense to make poetry-dynamic-versioning a Poetry plugin rather than a standalone package. Do you know what, if any, the arguments are for keeping it as a standalone package?

@qwenger
Copy link

qwenger commented Sep 2, 2021

Hi there,

Thanks a lot for bringing VCS-sourced dynamic versioning to poetry!

I do also think that this plugin should be combined with poetry-dynamic-versioning. I cannot answer @mrpgraae's question with certainty, but the README.md there says:

Since Poetry does not yet officially support plugins (refer to this issue) as of the time of writing on 2019-10-19, this package takes some novel liberties to make the functionality possible. As soon as official support lands, this plugin will be updated to do things the official way.

...so I guess (and hope!) that it will be "pluginized" soon (I don't know the ETA for poetry 1.2.x, though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants