Skip to main content

Utility functions for pip package management

Project description

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 packages
  • parse_frozen_requirements(frozen_reqs) - Parse frozen requirements into version dict
  • is_pip_installed_package(package_name, packages) - Check if package satisfies requirement
  • pip_install_packages(packages, flags=None) - Install packages with optional flags
  • unload_package(qualified_name) - Unload package from memory
  • extract_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.

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

comet_pip_utils-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comet_pip_utils-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file comet_pip_utils-0.1.0.tar.gz.

File metadata

  • Download URL: comet_pip_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for comet_pip_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f8bb979b656cb26ce03b51dfcf7414ec3a3ef6059efc87a50baee9038fe94706
MD5 53b83eab6860f6af1e74c4608f8649ac
BLAKE2b-256 a17a0220b4fb1e95a378aa381eef2a1d5a93820bbfb26240ffd52339d752bf1d

See more details on using hashes here.

File details

Details for the file comet_pip_utils-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for comet_pip_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64bf5d96536d296b98738b99eb35b2832d5e75e968be57e8cdc767149da5a8c8
MD5 33e064d50cc8f9a69dbd29a8da5e330e
BLAKE2b-256 91d4120805917c3f77f87b1cb0b00ae715e07e30cbd36acc579b65ed30605846

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page