Skip to main content

Run Python functions in isolated virtualenvs configured by separate requirements files.

Project description

compat-runtime

compat-runtime helps solve Python dependency conflicts by running functions inside isolated virtual environments created from separate requirements files. It is useful for compatibility testing, dependency isolation, and reproducing behavior across multiple dependency versions.

Features

  • Decorate a function with @runtime("requirements.txt").
  • Resolve relative requirements paths from the decorated function's source file.
  • Cache virtual environments by requirements-file hash.
  • Execute worker code through file-based IPC, avoiding command-line length limits.
  • Manage cached runtimes with the compat CLI.

Install

python -m pip install compat-runtime

For local development from a checkout:

python -m pip install -e .[test,release]

Usage

Create an app-specific requirements file:

pydantic==2.5.3

Use it from Python:

from compat import runtime


@runtime("requirements.txt")
def get_pydantic_version():
    import pydantic

    return pydantic.__version__


print(get_pydantic_version())

Arguments and return values must be picklable. Exceptions raised in the worker process are surfaced as compat.exceptions.WorkerError with the worker traceback attached.

Cache Management

compat list
compat invalidate requirements.txt
compat clear

Cache locations follow the host platform:

  • Windows: %LOCALAPPDATA%\compat_runtime\envs
  • macOS: ~/Library/Caches/compat_runtime/envs
  • Linux: $XDG_CACHE_HOME/compat_runtime/envs or ~/.compat_runtime/envs

Test

python -m pytest -q
python -m compileall -q compat

Build and Release

python -m build
python -m twine check dist/*
python -m twine upload --repository testpypi dist/*
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ compat-runtime==0.1.0
python -m twine upload dist/*

Publishing uses standard Twine credentials. Set TWINE_USERNAME=__token__ and TWINE_PASSWORD=<token> for the target package index before uploading.

Repository

Source code is published at:

https://github.com/tanishqjain123145/Compat

License

MIT

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

compat_runtime-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

compat_runtime-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for compat_runtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bfc5035e29c02d557d139f9eefe8980fd859093be024daa2d78f92da655038f7
MD5 b4eb81f2983596e4dcf21edcece2d717
BLAKE2b-256 383996d2fae8b8ca43d891a0dd8f41567ee2f113cdba7642157ec7e9446044d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for compat_runtime-0.1.0.tar.gz:

Publisher: workflow.yml on tanishqjain123145/Compat

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

File details

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

File metadata

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

File hashes

Hashes for compat_runtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e015030581452b96b0ced5daa3fc472a84e5aef8ae15b6c2fcaff91187fa88c9
MD5 54548472155efdf86b5f639002a54fcf
BLAKE2b-256 34a8663311bf9d0d155f135e79e84bc3cef5e11572bb182d67ca2edbc63c1e1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for compat_runtime-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on tanishqjain123145/Compat

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