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.6.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pkg_vers-0.0.6-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pkg_vers-0.0.6.tar.gz
  • Upload date:
  • Size: 5.3 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.6.tar.gz
Algorithm Hash digest
SHA256 4f50c9963cf65ed5a3b6792eb931c8988d2c42f351863c260d031f6a9e370d66
MD5 9636b08eccd8ca1dc72b803cbef322b1
BLAKE2b-256 7b8922ef87e15443c8fd47a8b663e813cd046bc9a98b5dcd7fd52ddd3351680c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pkg_vers-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 34313ab773e4e3c09f263e78aea1c61177551fe85b881fdb96d7ed9c6ad6fd08
MD5 b94bba4d6aed9ceebb7dbb6f80de570e
BLAKE2b-256 091005c764f2a3e48eef81617997b1f5dede2e8ca6b7fb5110fd368dc00fecc8

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