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

remove duplication of version in __init__ and remove not used variables #422

Open
alan-barzilay opened this issue Nov 29, 2023 · 2 comments

Comments

@alan-barzilay
Copy link
Collaborator

alan-barzilay commented Nov 29, 2023

probably something like:
__version__ = importlib.metadata.version('pipreqs')

refs:
https://docs.python.org/3/library/importlib.html
python-poetry/poetry#273

@alan-barzilay
Copy link
Collaborator Author

alan-barzilay commented Nov 29, 2023

actually, this might be better:

import importlib.metadata
import tomllib

try:
    with open("pyproject.toml", "rb") as f:
        pyproject = tomllib.load(f)
    __version__ = pyproject["tool"]["poetry"]["version"]
except Exception as e:
    __version__ = importlib.metadata.version('pipreqs')

(tomlib is new from version 3.11)

@alan-barzilay alan-barzilay changed the title remove remove duplication of version in __init__ and remove not used variables Nov 29, 2023
@alan-barzilay
Copy link
Collaborator Author

this may be useful in #411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant