Output only the version number with `poetry version`
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Feature Request
Running poetry version
outputs something to the nature of Project (<name>) version is 0.1.0
. There seems to be no way to only obtain the version (i.e. 0.1.0), which is what I personally expect poetry version
to output. It makes it a little bit more cumbersome to do automated version updates in continuous delivery server (e.g. get the current version number after a version update so that a repo can be tagged).
I would like to suggest either:
poetry version --number
(or another acceptable option name since not everyone uses numbers for versions) outputs only the version and not the project informationpoetry version
outputs only the version number andpoetry version -l
prints out the more descriptive version information.- Updating the FAQ with an example of how to get the version number by parsing stdout (along with an associated unit test). I’d feel more confident implementing a solution around parsing stdout if we can rely on the stdout not changing.
I’m happy to implement this solution however the maintainers see fit if the community believes it would make automated scripts around the package version easier. And I’m also open to writing an extension/plugin if poetry supports that.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Output only the version number with poetry version #1407
Running poetry version outputs something to the nature of Project (<name>) version is 0.1.0 . There seems to be no way to only...
Read more >Commands | Documentation | Poetry - Python dependency ...
--short (-s) : Output the version number only. --dry-run : Do not update pyproject.toml file. export #. This command exports the lock file...
Read more >Dependency version syntax for Python Poetry - Stack Overflow
The tilde ~ character tells Poetry to allow minor updates. If you specify a major, minor, and patch version, only patch-level changes are ......
Read more >poetry-dynamic-versioning - PyPI
Poetry's typical version setting is still required in [tool.poetry] , but you are encouraged to use version = "0.0.0" as a standard placeholder....
Read more >Dependency Management With Python Poetry
In the output, you should see a message that the installation is complete. You can run poetry --version in your terminal to see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@etijskens sure, one can do this in Python, but hardcoding the project path, including a separate python script in your repo just to print a version, and also ensuring that a toml parser is installed is not a simple solution at all. Especially if you are scripting a pipeline for continuous delivery and publishing of many different python projects.
Poetry’s main use case is for packaging and publishing, which as a result means that the version number is needed for many other things related to publishing the library (tagging the repo, adding the version string to the automated docs, etc).
For example, a script to do an automated version bump might look like:
In order to get the current version of the repo, I have to parse the output of
poetry version
, which is a sentence of text and not some sort of delimited structured text (like anls -l
for example). It is strange that I can do complex semantic versioning commands to update the version (e.g.poetry version major
), but I can’t do something as simple as get the version after it is updated without resorting to parsing text.Again, I appreciate the suggested solution in Python, but the purpose of this was to suggest it as a feature since getting the package version is a core aspect of publishing python projects. If the maintainers are happy with any of my suggested approaches, I’m more than happy to open a PR
It’s better. It would still be nice to have an option to just print the version.