diff --git a/README.md b/README.md index dee2872..b9387d7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The easiest Python environment manager. Create virtual environments for any Pyth Get the tool by running the following command: - MacOS / Linux: - + ```bash curl -L yen.tushar.lol/install.sh | sh ``` @@ -38,6 +38,9 @@ $ yen create venv -p 3.11 Downloading 3.11.5 ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 17.4/17.4 MB • 12.4 MB/s • 0:00:00 Created venv with Python 3.11.5 ✨ +By default the python-installation will be done in ~/.yen_pythons. +You can change this location by setting a different path using the environment variable `YEN_PYTHONS_PATH`. + $ source venv/bin/activate (venv) $ python --version diff --git a/src/yen/__init__.py b/src/yen/__init__.py index f6318ef..f218f39 100644 --- a/src/yen/__init__.py +++ b/src/yen/__init__.py @@ -1,4 +1,5 @@ """yen - Yet another Python environment manager.""" +import os import os.path import subprocess import tarfile @@ -6,7 +7,7 @@ from yen.downloader import download from yen.github import NotAvailable, resolve_python_version -PYTHON_INSTALLS_PATH = os.path.expanduser("~/.yen_pythons") +PYTHON_INSTALLS_PATH = os.getenv("YEN_PYTHONS_PATH") or os.path.expanduser("~/.yen_pythons") def ensure_python(python_version: str) -> tuple[str, str]: diff --git a/yen-rs/src/main.rs b/yen-rs/src/main.rs index 4780535..113b41c 100644 --- a/yen-rs/src/main.rs +++ b/yen-rs/src/main.rs @@ -22,7 +22,12 @@ lazy_static! { "https://api.github.com/repos/indygreg/python-build-standalone/releases/latest"; static ref RE: Regex = Regex::new(r"cpython-(\d+\.\d+.\d+)").expect("Unable to create regex!"); static ref MUSL: Regex = Regex::new(r"GNU|GLIBC|glibc").expect("Unable to create regex!"); - static ref PYTHON_INSTALLS_PATH: PathBuf = home_dir().join(".yen_pythons"); + static ref PYTHON_INSTALLS_PATH: PathBuf = { + match std::env::var("YEN_PYTHONS_PATH") { + Ok(yen_pythons_path) => PathBuf::from(yen_pythons_path), + Err(_) => home_dir().join(".yen_pythons"), + } + }; static ref YEN_CLIENT: Client = yen_client(); }