-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Make version in pyproject.toml
optional, or at least validate it *after* the plugins are run
#4299
Comments
Hello @tiangolo, thanks for FastAPI! 😃 🥇 In general I think it is a good idea to validate the On the other hand you are touching a topic that is discussed quite emotional in various places (e.g. in the discussion around PEP 621): How static should/must metadata of a package be? My personal opinion is, that name, version and dependencies are clearly static metadata and shouldn't be declared dynamically. AFAIK many people trying to receive the version from a git tag,because a build and/or deployment is triggered by adding the version as a git tag, right? At my company we have a different approach: A merge into the master branch triggers the deployment. The pipeline reads the version from the Until now Poetry follows the principal that there should be only one source of truth for the metadata and it's the fin swimmer |
Thanks for the response @finswimmer! Yep, I know it's a complex topic. 😅 And I understand that the expected main use case would be to set the version in Let me share my points of view and motivations here: I'm actually not that interested in setting the version in a git tag as much as in the I tried with a couple of packages using the sort-of-official trick you describe here: #2366 (comment) Nevertheless, I ended up having issues with conflicts with other packages also requiring the backport That's why I got super excited with the new plugin system and being able to do that in my projects. ✨ With the plugin, I can make it easier for me and for others, especially newcomers, to build packages with Python. That's one of the things I love about Poetry, that it makes it super simple and straightforward to manage projects, dependencies, and also packages. And after learning to use it just for dependencies, it's very straightforward to build an actual package, without having to use I guess that the general intention of the Python community in the future is to stop declaring a But then, let's say that the general consensus or the general accepted approach was to not declare a Then, in that case, with no As a side note, my plan is to move FastAPI, Typer, and everything else to Poetry using my plugin. 🚀 For me, the workaround of setting My request is mainly because I feel it could be confusing for newcomers building a new package. |
FWIW I, too have encountered issues with using This is probably a niche edge case, as the version is for an app, not a published library... but it's a real world example of the |
@finswimmer , I think there are many use-cases of dynamic versioning. For example, our project require nightly releases of our library. Updating the version manually every day is just not an option. So we need some automated way. |
@Conchylicultor I wonder why that's the case. Wouldn't running an automated version bump, e.g. |
I also have this problem but In the software world I am engaged with, using git versioning as the source of truth is best practice. Deviating from the git revision is only advised if the git revision is somehow lacking (rare). Idea being git is the root-most version, and we don't want to complicate the system needlessly. This is a perfectly rational approach to versioning python packages and it would be great if Poetry could support it. No breaking change required, |
also worth noting PDM has a nice way of doing this https://pdm.fming.dev/pyproject/pep621/#determine-the-package-version-dynamically |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ As another use-case, my company uses a monorepo where the server (written in Haskell) and client are versioned in lock-step, using the same source-of-truth |
For this, (and many other reason), I switched to flit (https://github.com/pypa/flit). Flit is only trying to one problem, so it end up working very nicely. I think poetry try to do to much, so end up having many bugs, edge cases. |
Feature Request
Thanks for Poetry! I'm a big fan. 🎉
I wanted to be able to keep my package versions in
__init__.py
, and with the new alpha supporting plugins I was able to create a plugin to read the version from it dynamically: https://github.com/tiangolo/poetry-version-pluginBut currently, Poetry checks and verifies if the
version
is set inpyproject.toml
, and if it is not set there, it terminates with an error.That means that even though the plugin is taking care of setting the package version, a dummy "version" is required in
pyproject.toml
, even though it is not really used.My feature request is to make the
version
field optional inpyproject.toml
.Or alternatively, check if the
version
is set in the Poetry object in memory after running the plugins. That way my plugin can set the version.Motivation
If users try to use that plugin (or any other similar one), they would have to set a
version
just to trick Poetry into thinking thepyproject.toml
has all the fields, while theversion
is not really used in the end. So, for the final result, it's an extra workaround step.The text was updated successfully, but these errors were encountered: