Skip to main content

pkg_vers is a utility that helps you determine the versions of packages imported in your Python scripts or Jupyter notebooks.

Project description

pkg_vers

pkg_vers is a utility that helps you determine the versions of packages imported in your Python scripts or Jupyter notebooks.

  • Use the get_versions(files) function to get the versions of all top-level packages imported in a list of Python scripts (.py) and Jupyter notebooks (.ipynb).
  • Use the CLI to quickly get package versions from the command line.

Features

  • Extract top-level imported packages from Python scripts and Jupyter notebooks.
  • Retrieve installed package versions using pip and mamba.
  • Provide a mapping of imported packages to their installed versions.
  • Command Line Interface (CLI) for quick access to package version information.

Installation

Make sure you have pkg_vers installed. If not, you can install it using pip:

pip install pkg_vers

Usage

Get Package Versions

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

Example:

from pkg_vers import get_versions

files = ['script1.py', 'notebook.ipynb']
package_versions = get_versions(files)
print(package_versions)

Get Package Versions from a Folder

To get the versions of all top-level packages imported in all .py and .ipynb files within a folder, use the get_versions(folder) function.

Example:

from pkg_vers import get_versions

folder_path = 'path/to/your/folder'
package_versions = get_versions(folder_path)
print(package_versions)

Command Line Interface (CLI)

You can use pkg_vers directly from the command line to get the versions of packages imported in your scripts, notebooks, or all files within a folder.

Get Package Versions

To use the CLI, simply run:

python -m pkg_vers get_versions <file1> <file2> ...

Replace <file1>, <file2>, etc., with the paths to your Python scripts or Jupyter notebooks.

Example:

python -m pkg_vers get_versions script1.py notebook.ipynb

Get Package Versions from a folder

To process all .py and .ipynb files within a folder, run:

python -m pkg_vers get_versions <folder>

Example:

python -m pkg_vers get_versions path/to/your/folder

This will output the versions of all top-level packages imported in the specified files or all files within the specified folder.

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

Uploaded Source

Built Distribution

pkg_vers-0.0.8-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pkg_vers-0.0.8.tar.gz
  • Upload date:
  • Size: 6.5 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.8.tar.gz
Algorithm Hash digest
SHA256 76b09fc70b5d64afae8ad5e5e61695dc5de9fa41b05246e69d35ce0b87d9d6ef
MD5 a1162f318abfedbe0de553b933c4347a
BLAKE2b-256 63ce70bcb7f1e8da43777cc2443bcc4061ffaa17ebc43c3a0e2b195b99e9cc4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pkg_vers-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 931110afa44c9589612d506f3a907cca517a6e5a9f1284ef1d7b862239b78074
MD5 d14a68fa4d828403693e891697390354
BLAKE2b-256 9145dffbfd546e29a919e19909f0369dedcc8ab888ab504750bf3ea4cd902336

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