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

Support finding project version from sources #4971

Closed
2 tasks done
pbarker opened this issue Jan 2, 2022 · 4 comments
Closed
2 tasks done

Support finding project version from sources #4971

pbarker opened this issue Jan 2, 2022 · 4 comments
Labels
kind/feature Feature requests/implementations

Comments

@pbarker
Copy link

pbarker commented Jan 2, 2022

  • 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

There are a number of workflows which would benefit from pulling the version parameter in pyproject.toml dynamically. PDM has a nice way of doing this:

[tool.pdm]
version = {from = "mypackage/__init__.py"}
[tool.pdm]
version = {use_scm = true}

Our use case involves using private Python modules which we prefer to install directly from git. In doing so, using the git revision produces an accurate and easily traceable version for the python package. The only way to replicate this today is to bump the version each time you commit, which is a lot of overhead, and there isn't a great way of automating this.

#4299 also mentions a use case for wanting to use __init__.py

It is worth noting tools like https://github.com/mtkennerly/poetry-dynamic-versioning cannot solve this problem when installing from git. The version is set on building the wheel which never happens on scm install, so you end up with a package version of 0.0.0. It's not clear to me if any plugin derived method could do this properly.

@pbarker pbarker added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Jan 2, 2022
@finswimmer
Copy link
Member

Hello @pbarker,

there are no plans to provide such a feature in Poetry, because we believe that the version is one of the static metadata and the pyproject.toml is the single source of truth for it.

However with the upcoming minor release (1.2) there will be a plugin system and there is already a plugin called poetry-version-plugin that provides what you are asking for.

fin swimmer

@pbarker
Copy link
Author

pbarker commented Jan 18, 2022

Hey @finswimmer, thanks for the response.

Yeah I've seen poetry-version-plugin, the issue we're hitting is the plugin is only called on build, which prohibits a SCM install flow. My company installs internal python packages from git because it removes the requirement of needing to host a PyPI. This seems to be a very common pattern that I've seen most places I've worked.

because we believe that the version is one of the static metadata and the pyproject.toml is the single source of truth for it.

Could that just be the default? I don't see anything in the PEP denoting that should be the case. In most other parts of the software world, the SCM version is preferred because its the root-most version. Lots of existing staple Python projects version their packages this way.

If it can't be the default, would there be a way to expand the scope of plugins to cover this? From reading the code it looks like version is pulled right when the config file is passed. Would it be possible to inject plugins there? Thanks

@pbarker
Copy link
Author

pbarker commented Jan 18, 2022

Also worth noting our current flow with Poetry now requires us to use Bump2Version to sync with git tags, you can see this is common practice from this issue here #1949. The UX around doing so is poor.

Its a very common and natural flow to want your package version to sync with SCM, I would go as far as to say it's best practice. It would be nice if there was at least an avenue of doing this in the project.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

3 participants