Skip to main content

Reuse installed Python packages from existing virtual environments.

Project description

PKGReuse

License

PKGReuse is an explicit Windows and Linux command-line wrapper that reuses compatible Python distributions already installed in other virtual environments. It can avoid downloading and unpacking a package when a safe local donor is available.

PKGReuse does not replace or intercept ordinary pip and uv commands. Local reuse is enabled only when you invoke the pkgreuse command.

PKGReuse 0.1 is alpha software. Use it in disposable virtual environments until its behavior has been validated for your workflow.

How resolution works

For a requirement such as filelock>=3,<4, PKGReuse scans its local environment index, filters locally installed versions against the requirement, and selects the highest satisfying local version. It delegates the original requirement to pip or uv only when the complete dependency closure cannot be reused locally. It does not query PyPI to maximize a locally satisfiable requirement.

Installation

py -m pip install pkgreuse

Run PKGReuse from an active standard Python virtual environment.

Usage

Use pip as the fallback installer:

pkgreuse pip install "requests>=2.31,<3"

Or use uv as the fallback installer:

pkgreuse uv pip install "requests>=2.31,<3"

On the first prefixed installation, PKGReuse automatically creates its local environment index. It first uses Conda, uv, and pip discovery hints, then performs a two-level scan around the active project and working directory. Every candidate is independently validated before it can become a donor.

To discover environments outside that nearby area, explicitly provide one or more roots. Explicit roots are scanned recursively, so they remain suitable for a deliberate wider inventory without a default full-disk crawl:

pkgreuse init C:\Users\you\Desktop
pkgreuse init "$HOME/projects" /opt

Useful diagnostic and planning commands include:

pkgreuse status
pkgreuse find requests
pkgreuse resolve "requests>=2.31,<3"

Safety model

PKGReuse validates the complete local dependency plan before changing the target. Package content may be hard-linked on the same volume, while distribution metadata is copied. It rejects stale donors, target conflicts, unsafe RECORD traversal, executable or donor-specific .pth files, and editable installations. Donor launchers are not copied. If transfer or final validation fails, files created by the transaction are rolled back.

Development

py -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
.\scripts\check-release.ps1

On Linux, run the equivalent checks directly:

python -m venv .venv
.venv/bin/python -m pip install -e '.[dev]'
.venv/bin/python -m ruff check .
.venv/bin/python -m ruff format --check .
.venv/bin/python -m mypy
.venv/bin/python -m pytest --cov=pkgreuse

The native NumPy check is opt-in because it requires a prepared compatible donor environment:

$env:PKGREUSE_NUMPY_REQUIREMENT = "numpy==2.3.3"
.\.venv\Scripts\python.exe -m pytest -m extended tests\extended\test_numpy_manual.py

See the resolution notes for the solver's local-maximization semantics.

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

pkgreuse-0.1.2.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

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

pkgreuse-0.1.2-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

Details for the file pkgreuse-0.1.2.tar.gz.

File metadata

  • Download URL: pkgreuse-0.1.2.tar.gz
  • Upload date:
  • Size: 52.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pkgreuse-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d3563c7d96d0b41a4e8a9a73cffbe0394b612eb7aea8eca1dc264ad0a39b5f99
MD5 bdcfc0ee4990c922a1127728f63442a2
BLAKE2b-256 a58b0f09f8c52c8c79abbd10b0650a0ee630d3edb4ff1a49214f1e8e0bd7edfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgreuse-0.1.2.tar.gz:

Publisher: publish.yml on khalilurehman-masood/pkgreuse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pkgreuse-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pkgreuse-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 49.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pkgreuse-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37e81c561b58d00f3a6e66c9b0b700ab12d83d247461cfbba868677dc645407e
MD5 067b1c066241192b49581eaa31b1b654
BLAKE2b-256 c6353fc9c35e17f9f28710cc011d5538cbb38c1a87f22cae21e61fda34dca69c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgreuse-0.1.2-py3-none-any.whl:

Publisher: publish.yml on khalilurehman-masood/pkgreuse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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