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
andmamba
. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pkg_vers-0.0.2.tar.gz
.
File metadata
- Download URL: pkg_vers-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0491b4a05ba55c4b5afef5cc28f8ff7ab32a1f0797c15b9782cd6091baca2594 |
|
MD5 | 2efe11b2e676bba2d408b26722d1cc39 |
|
BLAKE2b-256 | a9fcdfc252f66eaeb6f7562ca44eab185296447d48d8a3d3d343fe8a969d6b83 |
File details
Details for the file pkg_vers-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pkg_vers-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5828b85924d82f028b52aa76800a0359a81ad9b31056c8e165f50ac854ecd4fc |
|
MD5 | 8233ac0e6a5e2740cbc142c52a9c3400 |
|
BLAKE2b-256 | 82bb085d2c33cd93de3b43d0654317b680ab75726e837e120e0ff9a7a18d5ee1 |