Download code/scripts/lib/env.sh from nileshsarkar-ai/CausalGrok: direct link, hf CLI and curl.
- Browser
- Download file 982 Bytes
-
https://huggingface.co/nileshsarkar-ai/CausalGrok/resolve/main/code/scripts/lib/env.sh
- Command line
-
hf download hf://nileshsarkar-ai/CausalGrok/code/scripts/lib/env.sh
-
curl -L -o env.sh https://huggingface.co/nileshsarkar-ai/CausalGrok/resolve/main/code/scripts/lib/env.sh
982 Bytes
| # scripts/lib/env.sh | |
| # Resolves which python to use, in priority order: | |
| # 1. $PYTHON env var, if set | |
| # 2. $CONDA_PREFIX/bin/python, if a conda env is active | |
| # 3. ~/anaconda3/envs/causalgrok/bin/python, if it exists | |
| # 4. system python, with a warning | |
| # | |
| # Source this; call `resolve_python` to set the global $PYTHON. | |
| resolve_python() { | |
| if [[ -n "${PYTHON:-}" ]] && [[ -x "${PYTHON}" ]]; then | |
| return | |
| fi | |
| if [[ -n "${CONDA_PREFIX:-}" ]] && [[ -x "${CONDA_PREFIX}/bin/python" ]]; then | |
| PYTHON="${CONDA_PREFIX}/bin/python" | |
| return | |
| fi | |
| local cand="${HOME}/anaconda3/envs/causalgrok/bin/python" | |
| if [[ -x "${cand}" ]]; then | |
| PYTHON="${cand}" | |
| return | |
| fi | |
| if command -v python >/dev/null 2>&1; then | |
| PYTHON="$(command -v python)" | |
| echo " warning: causalgrok env not found; using ${PYTHON}" >&2 | |
| return | |
| fi | |
| echo " error: no python interpreter found" >&2 | |
| return 1 | |
| } | |