Skip to main content

pkg_vers is a utility to determine versions of top-level packages used in your project

Project description

pkg_vers is a utility that helps you determine the versions of packages imported in your Python scripts. The main use case is to use the get_package_versions_from(files) function to get the versions of all top-level packages imported in a list of scripts.

Features

  • Extract top-level imported packages from Python scripts.
  • Retrieve installed package versions using pip and mamba.
  • Provide a mapping of imported packages to their installed versions.

Usage

Basic Usage

To get the versions of all top-level packages imported in your Python scripts, use the get_package_versions_from(files) function.

Example:

from pkg_vers import get_package_versions_from

files = ['script1.py', 'script2.py']
package_versions = get_package_versions_from(files)
print(package_versions)

Helper Functions

For more nuanced use cases, the following helper functions are exposed:

  • get_imported_top_level_packages(script_paths): Extract top-level imported packages from a list of script paths.
  • get_installed_packages(): Retrieve a dictionary of installed packages and their versions using pip and mamba.
  • get_package_version(package): Get the version of a specific package using importlib.
  • get_top_level_package_versions(imported_packages, installed_packages): Get versions of a list of imported packages based on the installed packages.
  • get_package_versions_from_ipynb(): Get versions of imported packages from an active Jupyter Notebook by name.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkg_vers-0.0.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pkg_vers-0.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pkg_vers-0.0.4.tar.gz.

File metadata

  • Download URL: pkg_vers-0.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.19

File hashes

Hashes for pkg_vers-0.0.4.tar.gz
Algorithm Hash digest
SHA256 742fe46299d10c5f7724c41ce0ea017af4ae1ea44d3c4b406143afc275793968
MD5 d06b3d1da1fee4de4cbafad221e2a2cc
BLAKE2b-256 57f8048a4debf7dba069d577ad8b68872357f2a52b8c0ccdfb854d0b4065b0e4

See more details on using hashes here.

File details

Details for the file pkg_vers-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pkg_vers-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.19

File hashes

Hashes for pkg_vers-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b8354a36ba6e5a3cf14b246dcf8295bb2c519f6afa06ef42be170569ec33061f
MD5 5730d40819d375f9e972993837507be9
BLAKE2b-256 4061f4665c8f2b19c9a0fd07b0abf95b2d4120a850cadf7ec1ba0f601ea8f606

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page