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.0.tar.gz (49.9 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.0-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pkgreuse-0.1.0.tar.gz
  • Upload date:
  • Size: 49.9 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.0.tar.gz
Algorithm Hash digest
SHA256 e40088b042683407f3345232b9a29752610f296c12d3ed1ebd790f0996e2e5a8
MD5 a5050d4f936bbd3960e5c23485a378bf
BLAKE2b-256 4173df59a5c357dd8f3eb9ca89eb63dc2d74d096a1ac71ac5ab455e4c54dbbb6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pkgreuse-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 47.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0be202d63d4c8de2625407d51a9151544197e0b957d7b7b4cda223f690537d02
MD5 8a0bd46da613c2204308af3970cd3e4f
BLAKE2b-256 1d136542b514c274babc7f4268122abf113229b903d19cc5a3e3fc8c59649a02

See more details on using hashes here.

Provenance

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