Skip to main content

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 install_packages(files) function to install all top-level packages imported in the specified Python scripts or Jupyter notebooks.
  • Use the CLI to quickly get package versions and install packages from the command line.

Features

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

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)

Install Packages

To install all top-level packages imported in your Python scripts and Jupyter notebooks, use the install_packages(files) function.

Example:

from pkg_vers import install_packages

files = ['script1.py', 'notebook.ipynb']
install_packages(files)

Install Packages from a Folder

To install all top-level packages imported in all .py and .ipynb files within a folder, use the install_packages(folder) function.

Example:

from pkg_vers import install_packages

folder_path = 'path/to/your/folder'
install_packages(folder_path)

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 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.

Install Packages

To use the CLI to install packages, run:

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

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

Example:

python -m pkg_vers install_packages script1.py notebook.ipynb

Install Packages from a Folder

To use the CLI to install packages, run:

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

Contributing

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

License

This project is licensed under the MIT License.

Release files for pkg-vers 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pkg-vers 0.1.2
File Size Uploaded
pkg_vers-0.1.2.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pkg-vers 0.1.2
File Interpreter ABI Platform
pkg_vers-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / pkg_vers-0.1.2.tar.gz

Download URL pkg_vers-0.1.2.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c3967b1f111986e868b0957c95c5959cee3e17dba6bea8812d6405474fdd94ca
BLAKE2b-256 checksum
How to use checksums
ca194b88b526c374564c9eec9b0eac16b51974b6366598ab39102a459380276d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.19

Release files / pkg_vers-0.1.2-py3-none-any.whl

Download URL pkg_vers-0.1.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9598869083759afeb91fbc1adc0f74cf23ee41ba2157097fded4e4b8c20fe31b
BLAKE2b-256 checksum
How to use checksums
8a1b6f06da8cece4a5eab8f069bb38675636993f7c9bcbfa89b343cf33f4effe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page