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

Sanity check python package versions #3507

Open
VRehnberg opened this issue Nov 14, 2024 · 0 comments
Open

Sanity check python package versions #3507

VRehnberg opened this issue Nov 14, 2024 · 0 comments

Comments

@VRehnberg
Copy link
Contributor

Sometimes the wrong package version may be installed, see easybuilders/easybuild-framework#4706 which introduces a fix for a known way this could happen.

To catch similar issues it would probably be good to sanity check the version of installed packages.

Some possibilities:

  • Parse pip list --format=json or pip show %(name)s
    • Requires pip
  • Run from pkg_resources import get_distribution; assert get_distribution(%(name)s).version == %(version)s
    • Requires setuptools
  • Run import %(modulename)s; from importlib.metadata import version; assert version('%(modulename)s') == %(version)s
    • Requires Python>=3.8 or importlib_metadata
  • Run import %(modulename)s; if hasattr(%(modulename)s, '__version__'): assert %(modulename)s.__version__ == %(version)s
    • Packages not defining __version__ will not be sanity checked
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