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.
Release files for env-cache 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| env_cache-0.2.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| env_cache-0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size:10.5 kB
Release files / env_cache-0.2.tar.gz
| Download URL | env_cache-0.2.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8abf5ba2652e125b6ee8e2c31a65fbdded6d8320d8c45d7d2da766b9266992f
|
|
BLAKE2b-256 checksum How to use checksums |
a08fdf442e2f4bcc87a83db733e6a497c6f7095e0f9a88f453311e100447d33a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2024.
Transparency logRelease files / env_cache-0.2-py2.py3-none-any.whl
| Download URL | env_cache-0.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
61b890f438b020688197f3394c84556810e534aad5c0b58d079017138dadf46f
|
|
BLAKE2b-256 checksum How to use checksums |
2383fbad72ef26e913500efc4d9da5975609ec0455294ea4034e3dfc37463d44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2024.
Transparency log