Skip to main content

Get a Python environment for a Python version and requirements.txt file

Project description

Get a Python environment for a Python version and requirements.txt file

env_cache manages a collection of Python environments. You request an environment for a specific Python version and a set of requirements (preferably with pinned versions, like from pip freeze). It can either create a new environment with these packages, or retrieve one it already made with the same arguments.

To get different versions of Python, env_cache can use pyenv, conda, or spack. It can also work with a single ‘fixed’ Python interpreter to create virtualenvs - in this case, only one Python version is available.

Usage (with pyenv):

import sys
from pathlib import Path

from env_cache import PyenvEnvMaker, EnvsManager

if len(sys.argv) != 3:
    sys.exit("Usage: eg-pyenv.py 3.8.11 path/to/requirements.txt")

py_version, reqs_path = sys.argv[1:]
reqs = Path(reqs_path).read_text('utf-8')

envmgr = EnvsManager(Path('my-envs'), PyenvEnvMaker())
env_dir = envmgr.get_env(py_version, reqs)

It returns a pathlib Path object (env_dir above) pointing to the environment directory. Python can be run from bin/python within this directory.

It also records each time an environment is requested in a crude usage.csv file in the environment directory. This is meant to help with cleaning up unused environments, but it may go away or change completely in a future version.

This package is written primarily for internal use at European XFEL, so it’s fairly rough, and we might make breaking changes without warning.

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

env_cache-0.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

env_cache-0.2-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file env_cache-0.2.tar.gz.

File metadata

  • Download URL: env_cache-0.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for env_cache-0.2.tar.gz
Algorithm Hash digest
SHA256 d8abf5ba2652e125b6ee8e2c31a65fbdded6d8320d8c45d7d2da766b9266992f
MD5 29d860a684fbd9db3a7dbcd97c3ac291
BLAKE2b-256 a08fdf442e2f4bcc87a83db733e6a497c6f7095e0f9a88f453311e100447d33a

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_cache-0.2.tar.gz:

Publisher: tests.yml on European-XFEL/env-cache

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

File details

Details for the file env_cache-0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: env_cache-0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for env_cache-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 61b890f438b020688197f3394c84556810e534aad5c0b58d079017138dadf46f
MD5 9e2b4e72688b0d1e692d42d1dc7fecbe
BLAKE2b-256 2383fbad72ef26e913500efc4d9da5975609ec0455294ea4034e3dfc37463d44

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_cache-0.2-py2.py3-none-any.whl:

Publisher: tests.yml on European-XFEL/env-cache

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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page