Skip to content

Commit

Permalink
introduce env-var YEN_PYTHONS_PATH (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
woutervh authored Oct 6, 2023
1 parent c88cdc8 commit 45b66e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/yen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""yen - Yet another Python environment manager."""
import os
import os.path
import subprocess
import tarfile

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]:
Expand Down
7 changes: 6 additions & 1 deletion yen-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 45b66e2

Please sign in to comment.