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_specific_package_versions(imported_packages, installed_packages): Get versions of a list of imported packages based on the installed packages.

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

Uploaded Source

Built Distribution

pkg_vers-0.0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pkg_vers-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 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.1.tar.gz
Algorithm Hash digest
SHA256 8558d589dbe877c035a5787125d7ffcf5fcd503d57c14d846ed3fa60edd3e912
MD5 ad3bca5e01c3f9648c4e637aa957972a
BLAKE2b-256 3ce40553a265b644f6eb878e39abce079f2ca76334d307e4ded1fe93d5d06ce2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pkg_vers-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 50aed9cbbc3a545bccc705fe80f5fb9e774f3377abab0fa351154648c5756797
MD5 058cddc0a16461d692a32f0064bebbd0
BLAKE2b-256 3a0e071e48e9dc9496bd5900e6d8051640d80e52603700d66978160207ce9073

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