Comet Pip Utils
A Python package providing utility functions for pip package management and environment analysis.
Installation
pip install comet-pip-utils
Features
- Get installed pip packages in the current environment
- Parse and analyze frozen requirements
- Check if packages are installed and satisfy version constraints
- Install packages programmatically with custom flags
- Unload packages from memory
- Extract package names from requirement strings
Usage
Get Installed Packages
from comet_pip_utils import get_pip_packages
# Get all installed packages
packages = get_pip_packages()
print(packages)
# Output: ['numpy==1.21.0', 'pandas==1.3.0', ...]
Parse Frozen Requirements
from comet_pip_utils import parse_frozen_requirements
frozen_reqs = ['numpy==1.21.0', 'pandas==1.3.0']
installed = parse_frozen_requirements(frozen_reqs)
print(installed)
# Output: {'numpy': Version('1.21.0'), 'pandas': Version('1.3.0')}
Check Package Installation
from comet_pip_utils import is_pip_installed_package
# Check if a package is installed with version constraint
packages = get_pip_packages()
is_installed = is_pip_installed_package('numpy>=1.20.0', packages)
print(is_installed) # True or False
Install Packages Programmatically
from comet_pip_utils import pip_install_packages
# Install a single package
errors = pip_install_packages('requests')
# Install multiple packages
errors = pip_install_packages(['requests', 'numpy'])
# Install with flags
errors = pip_install_packages('requests', flags=['--user', '--no-deps'])
Unload Packages
from comet_pip_utils import unload_package
# Unload a package from memory
unload_package('numpy==1.21.0')
Extract Package Names
from comet_pip_utils import extract_package_name
# Extract package name from requirement string
package_name = extract_package_name('numpy>=1.20.0')
print(package_name) # 'numpy'
API Reference
Functions
get_pip_packages()- Get list of installed packagesparse_frozen_requirements(frozen_reqs)- Parse frozen requirements into version dictis_pip_installed_package(package_name, packages)- Check if package satisfies requirementpip_install_packages(packages, flags=None)- Install packages with optional flagsunload_package(qualified_name)- Unload package from memoryextract_package_name(package_name)- Extract package name from requirement string
Requirements
- Python 3.7+
- packaging>=21.0
License
Proprietary - Copyright (C) 2015-2023 Comet ML INC
This file can not be copied and/or distributed without the express permission of Comet ML Inc.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
comet_pip_utils-0.2.0.tar.gz
(9.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comet_pip_utils-0.2.0.tar.gz.
File metadata
- Download URL: comet_pip_utils-0.2.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4000ca348799b70a5183ccde5e3874ee525fb941a3975d67b559143a96f9b843
|
|
| MD5 |
090033e012a4bfa1f727d1a3fa2a0c7d
|
|
| BLAKE2b-256 |
527a1002e78a787faf4cd5030072a2f1fdf85f91287f5da5874c6a786b745137
|
File details
Details for the file comet_pip_utils-0.2.0-py3-none-any.whl.
File metadata
- Download URL: comet_pip_utils-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
609a14c903c66fd6ba6dfb8ff41104a8d31b3c952932df72e523d5f080cee511
|
|
| MD5 |
10d399307fc364925698f08061401f23
|
|
| BLAKE2b-256 |
f124748e0f46116b392d6d63ed26395b70150689dd6ef4fe0e6432248a98263a
|