question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable reading project's version number dynamically from somewhere other than pyproject.toml

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

I’m working on a project where we would like to adopt poetry. One aspect of our long-established workflow is that our version numbers are maintained a changelog file. We currently parse that file in setup.py to ensure that when we install the project, the version number is always correct.

poetry seems to only support reading the version from pyproject.toml which is obviously a static configuration file and so doesn’t support logic as setup.py does. Is there, or could there be, a way to dynamically read the version from somewhere else? (The obvious workaround is to make the change manually ourselves as part of our release process, but anything you rely on a human to do is liable to suffer human error sooner or later!)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:21
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
tiangolocommented, May 27, 2021

Cross-posting my comment from: https://github.com/python-poetry/poetry/pull/2366#issuecomment-849615115 as it seems it’s relevant here too.

Sorry if it feels like spam, but I think people subscribed to this issue might not be subscribed to that one and could miss this.


I just made a plugin (available with Poetry 1.2.0a1 and above) to read the version from an __init__.py file:

# __init__.py

__version__ = "0.1.0"

or from a git tag, set with a GitHub release or with:

$ git tag 0.1.0

I thought this could be useful for others here too.

https://github.com/tiangolo/poetry-version-plugin

7reactions
finswimmercommented, Aug 25, 2020

Hello @burrscurr,

please see my comment at https://github.com/python-poetry/poetry/pull/2366#issuecomment-652418094 about what you can do.

Hello @maxgrenderjones,

this is a question that raises from time to time. Also me was asking this a while ago (https://github.com/python-poetry/poetry/issues/1314#issuecomment-530366576). However, generate or read the version number dynamic from somewhere, makes it hard for dependency resolution tools like poetry, to get this value, when it needs to install something from source. Version numbers should belong to the static metadata and there should be only one place of truth for it. In case of poetry this is the pyproject.toml. Saying this we currently tend to not implement any dynamic reading from another place.

fin swimmer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard way to embed version into Python package?
There is only one place that the version number is written down, so there is only one place to change it when the...
Read more >
Dynamic project names and PEP 621 - Packaging
I am a fan of the static package configuration espoused by pyproject.toml and PEP 621. As I migrate projects to use it, I...
Read more >
Packaging Your Python Code With pyproject.toml - YouTube
Learning how to package your code can seem overwhelming. This complete 52 minute conversation takes you through the steps one at a time, ......
Read more >
The pyproject.toml file | Documentation | Poetry
The pyproject.toml file The tool.poetry section of the pyproject.toml file is composed of multiple sections. name The name of the package.
Read more >
Poetry - The Blue Book
lock to ensure that the package versions are consistent for everyone working on your project. As a result you will have all dependencies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found