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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file env_cache-0.1.tar.gz
.
File metadata
- Download URL: env_cache-0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89d50b19e45fee92eebefe532daa65c6384ad5ef5bcf4c285aa00880f85cd1f |
|
MD5 | c37e4d623fb99377ff89002b2b615627 |
|
BLAKE2b-256 | 3c36de4be1adf24a4b9c5339767541b7468b4f24de7ede02583c640187bff193 |
File details
Details for the file env_cache-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: env_cache-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56f4b739ba002ce8c0c8f1c15c42ac2bd181835d0ad3b347a2734ef7b4b2cef5 |
|
MD5 | a764c8c46a55b5eaf549d23dc48a84fe |
|
BLAKE2b-256 | 1c3e885f4de40c9e7118dd1b9c7964fc48606fb14837d5b870bec2fdfdb3d7a0 |