You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried to investigate how to determine robustly the version of a package in the python environment.
Currently I know of no robust way that would be useable in local development.
module.__version__ does not always work and needs to be manually populated by the package owner - it is well possible to release a package without the __version__ attribute.
But this seems to retrieve the version from when the package was installed in the environment, irrespective of any updates made to the package later that may have changed __version__ or pyproject.toml. This makes it dodgy for local development.
Does anyone know a way that works under both conditions? That is: (a) for any python package released on pypi, even if the maintainer forgets to populate common attrbiutes; (b) for local development with an editable environment, robust to versio changes in the editable environment.
maintenanceContinuous integration, unit testing & package distribution
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've tried to investigate how to determine robustly the version of a package in the python environment.
Currently I know of no robust way that would be useable in local development.
module.__version__
does not always work and needs to be manually populated by the package owner - it is well possible to release a package without the__version__
attribute.I also found a way using
importlib
:But this seems to retrieve the version from when the package was installed in the environment, irrespective of any updates made to the package later that may have changed
__version__
orpyproject.toml
. This makes it dodgy for local development.Does anyone know a way that works under both conditions? That is: (a) for any python package released on
pypi
, even if the maintainer forgets to populate common attrbiutes; (b) for local development with an editable environment, robust to versio changes in the editable environment.Beta Was this translation helpful? Give feedback.
All reactions