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

poetry new generate _version.py and just use it, for bump version #4070

Closed
2 tasks done
podhmo opened this issue May 16, 2021 · 4 comments
Closed
2 tasks done

poetry new generate _version.py and just use it, for bump version #4070

podhmo opened this issue May 16, 2021 · 4 comments
Labels
kind/feature Feature requests/implementations

Comments

@podhmo
Copy link

podhmo commented May 16, 2021

  • 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.

I read #144 and #2614 (comment)

Feature Request

First of all, poetry version <version> not a bumping version of the __init__.py's __version__. this is discussed many times, and a workaround exists.
But, current work-around, using importlib.metadata.version() seem overkill for me.

This is the minimum approach of the crazy idea using astor #1354.

details

in poetry new.

  1. generate _version.py (or __version__.py ?)
  2. generated __init__.py reference it

in poetry version <version>

  1. bump version of pyproject.toml
  2. if _version.py exists, regenerate _version.py

That's all.

examples

_version.py

# (the comment, something like "this is auto generated file")
__version__ = "0.1.0"

init.py

from <package name>._version import __version__  # noqa: F401
@podhmo podhmo added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels May 16, 2021
@finswimmer
Copy link
Member

Hello @podhmo,

using importlib.metadata.version() is not a workaround. It is the solution, because it reads the metadata that were installed. Since python 3.8 this is also build-in in python. So you get this method for free, without any additional dependencies.

fin swimmer

@podhmo
Copy link
Author

podhmo commented Jun 5, 2021

Yes, I know using importlib.metadata.version() can solve this problem.

This is just an implementation detail, but when loading a package created by poetry, each of this for-loop to get the package costs a bit with a huge virtualenv.

https://github.com/python/cpython/blob/fa106a685c1f199aca5be5c2d0277a14cc9057bd/Lib/importlib/metadata/__init__.py#L520-L526

However, if you treat it as a fixed cost when loading. the closing of this issue is ok.
(performance issue has not occurred, currently)

@podhmo
Copy link
Author

podhmo commented Jun 5, 2021

#2768

Oh, I see.

In this PR, the output of version information to the source code is stopped.
I like this. The version info in the package is out of poetry's Responsibilities.

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
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