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 scans every local fixed-drive root on Windows and / on Linux, while pruning operating-system trees and skipping inaccessible paths. Manual initialization with narrower roots is optional and can make discovery faster on very large filesystems:

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.1.tar.gz (50.3 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.1-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pkgreuse-0.1.1.tar.gz
  • Upload date:
  • Size: 50.3 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.1.tar.gz
Algorithm Hash digest
SHA256 9599a8f30196b78352da24226eb4e2e010c0790be3926c3b4c57a518a00aef83
MD5 f86a607f5e29216d8f627b039332d9eb
BLAKE2b-256 b78c63f705fb6724805821c9406e1484cb351c1ad8fbdd237be2af820146ac85

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgreuse-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pkgreuse-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 48.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60d57cdbb3a3096dc393f56288c0f7faaa41b88eddc54014cb95c8f2b41dd3e5
MD5 d5978ecf78d5617037d8e958ed60175e
BLAKE2b-256 9c9ca16ca7f8ddacb91a1c45d14613f96cb9398d958dbb12413f13eacf686780

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgreuse-0.1.1-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