Skip to main content

Run Python functions in isolated virtualenvs with separate dependency sets.

Project description

compat-runtime

Run individual Python functions inside isolated virtual environments, each with its own requirements.txt.

compat-runtime is built for real dependency-conflict situations: testing a function against multiple library versions, isolating a risky dependency, or reproducing behavior from an older dependency stack without changing your main application environment.

Install the package as compat-runtime, then import it as compat.

python -m pip install compat-runtime
from compat import runtime

Quick Start

Create a requirements file next to your Python module:

pydantic==2.5.3

Decorate the function that should run in that dependency environment:

from compat import runtime


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

    return pydantic.__version__


print(get_pydantic_version())

On first call, compat-runtime creates a cached virtual environment, installs the requirements, runs the function in a worker process, and returns the result to your main Python process. Later calls reuse the cached environment.

Why Use It?

  • Test one codebase against old and new dependency versions.
  • Keep conflicting dependencies out of your main environment.
  • Reproduce production or legacy behavior from a pinned requirements file.
  • Run dependency-heavy code only where it is needed.
  • Avoid command-line length limits by using file-based IPC internally.

Path Resolution

Relative requirements paths are resolved from the decorated function's source file first, then from the current working directory. This means code can be run from another directory and still find the right requirements file.

@runtime("runtimes/pydantic-v1.txt")
def parse_with_old_pydantic(data):
    import pydantic

    return pydantic.__version__

Return Values and Errors

Arguments and return values must be picklable because calls cross a process boundary.

If the worker function raises an exception, the host process receives compat.exceptions.WorkerError with the original exception type and worker traceback attached.

CLI

Use the compat command to inspect and manage cached runtimes:

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

Development

python -m pip install -e .[test,release]
python -m pytest -q
python -m compileall -q compat

Build and validate release artifacts:

python -m build
python -m twine check dist/*

Publishing

This project is published from GitHub Actions using PyPI Trusted Publishing. Creating and pushing a version tag such as v0.1.1 runs the release workflow.

Verify an uploaded release with:

python -m pip install compat-runtime==0.1.1
python -c "import compat; print(compat.__version__)"

Repository

Source code is available 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.1.tar.gz (11.7 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.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: compat_runtime-0.1.1.tar.gz
  • Upload date:
  • Size: 11.7 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.1.tar.gz
Algorithm Hash digest
SHA256 2bdcadb14e3b87dd4a1e55a336c7c6d25460571894df8569166a6bbd9dd38cc3
MD5 6369973fee15b1face5887496aeaf49c
BLAKE2b-256 45a6a5ba1f6787119d4c4f476668618f866f6f16c5ccd4307284d69a84037af3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: compat_runtime-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1893dbe65fc68098bfd342ae9dbd32e5ac34c73a9fd28e2c0fa03c70104f157f
MD5 596bb80a7aa60c3465ed3118bac5235b
BLAKE2b-256 d154207ba47462de3547ab95a69c51604ab7ac3e796597d32b96fa08e71bdaf7

See more details on using hashes here.

Provenance

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