mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-06-03 11:21:49 -05:00
23 lines
594 B
Python
23 lines
594 B
Python
import os, json
|
|
from pathlib import Path
|
|
|
|
DEFAULT_VENV = ".venv"
|
|
CONFIG_FILE = ".tinyrc"
|
|
|
|
|
|
def get_venv_path() -> Path:
|
|
"""
|
|
Fetch venv in case users have a custom path
|
|
"""
|
|
print(f"running this from {os.getcwd()}")
|
|
if "VENV_PATH" in os.environ:
|
|
return Path(os.environ["VENV_PATH"]).expanduser().resolve()
|
|
|
|
if Path(CONFIG_FILE).exists():
|
|
try:
|
|
cfg = json.load(open(CONFIG_FILE))
|
|
return Path(cfg.get("venv_path", DEFAULT_VENV)).expanduser().resolve()
|
|
except Exception:
|
|
pass
|
|
|
|
return Path(DEFAULT_VENV).resolve() |