Skip to main content

Professional runtime package manager for Python — install, manage and query packages directly from code

Project description

pypins

Professional Runtime Package Manager for Python

pypins provides a clean, secure, and powerful interface to manage Python packages directly from your code.
It eliminates the need for fragile subprocess calls while offering a simple and elegant API.

import pypins as pip

# Install packages programmatically
pip.install("requests>=2.31")

# Smart installation (only if missing)
pip.ensure_installed(["pandas", "numpy"])

# Check for outdated packages
outdated = pip.outdated()
for pkg in outdated[:3]:
    print(f"{pkg['name']}: {pkg['current_version']}{pkg['latest_version']}")

# Full control with custom indexes
pip.install("torch", index_url="https://download.pytorch.org/whl/cpu")

pypins is designed for developers who need reliable, auditable, and maintainable dependency management inside applications, scripts, notebooks, and deployment tools.

Key Features

  • Simple and Intuitive API — Perform complex pip operations with minimal code.
  • Security First — Executes pip through the official python -m pip interface. No shell execution.
  • Robust Input Validation — Prevents invalid or malicious package specifiers.
  • Advanced Capabilities — Support for custom indexes, constraints, editable installs, and requirements files.
  • High Performance — Leverages importlib.metadata for fast read operations.
  • Rich Feedback — Detailed PipResult objects and a complete exception hierarchy.
  • Special Utilitiesoutdated(), ensure_installed(), install_requirements(), and more.
  • Zero External Dependencies — Lightweight and reliable in any environment.
  • Production Ready — Fully typed, well-documented, and suitable for critical systems.

Installation

pip install pypins

Quick Examples

Basic Usage

from pypins import pip

# Install
pip.install("requests")

# Install with version constraint
pip.install("django>=4.2,<5.0")

# Install multiple
pip.install(["fastapi", "uvicorn[standard]"])

# Upgrade
pip.install("requests", upgrade=True)

# Quiet mode
pip.install("black", quiet=True)

Working with Custom Mirrors

pip.install(
    "torch",
    index_url="https://download.pytorch.org/whl/cpu"
)

# Multiple extra indexes
pip.install(
    "some-private-package",
    extra_index_urls=[
        "https://pypi.company.com/simple",
        "https://another-mirror.com/simple"
    ]
)

Checking Installed Packages

from pypins import pip

print(pip.is_installed("requests"))        # True / False
print(pip.get_version("requests"))         # "2.32.3"

for pkg in pip.list_installed():
    print(f"{pkg.name}=={pkg.version}")

print(pip.freeze())   # requirements.txt style string

Error Handling

from pypins import pip, PipError, PackageNotFoundError

try:
    pip.install("nonexistent-package-xyz")
except PipError as e:
    print("Installation failed:", e)
    print("stderr:", e.stderr)

API Reference

Function Description Returns
install() Install package(s) PipResult
uninstall() Uninstall package(s) PipResult
is_installed() Check if package exists bool
get_version() Get installed version str
list_installed() List all installed packages list[PackageInfo]
freeze() Get pip freeze output str

Security

  • Never uses shell=True
  • All package names are validated
  • Uses the current Python interpreter (sys.executable -m pip)
  • No arbitrary command execution

Roadmap (planned)

  • Async support (async def install(...))
  • Progress callbacks / rich live output
  • requirements.txt support (pip.install_requirements("requirements.txt"))
  • Virtual environment management helpers
  • Better error messages with suggestions

License

MIT License


pypins — Because running pip from code should be simple and safe.

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

pypins-1.0.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

pypins-1.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pypins-1.0.0.tar.gz.

File metadata

  • Download URL: pypins-1.0.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pypins-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f78f7f1a66934c2c51d9e24d3fdaaa8936c8c3dab1ec7c2c2e6195b800a166e9
MD5 d0152d1a133d2f464fb723d64218db21
BLAKE2b-256 2b2969814d87894200d4958e0e97b4b185f986af6b11599d0ee93e8630950150

See more details on using hashes here.

File details

Details for the file pypins-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pypins-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pypins-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e458250d384b0bf66ab39806a9ff8358732efa1727c1be7b4f94673f2449c2ff
MD5 4d24e00fefe9994b4cafd0bab94e4d82
BLAKE2b-256 d806fd71a3d5e17c4f42f8ef249ba288b288fe42d9994378cf5151a19dc8cf81

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