OILS / build / dev-shell.sh View on Github | oils.pub

86 lines, 30 significant
1# Sets $PATH to the locations of some precompiled binaries.
2# An alternative to nix-shell.
3#
4# Also sets PYTHONPATH and R_LIBS_USER
5#
6# Note: must run under /bin/sh, because _bin/shwrap/* tools use /bin/sh
7#
8# Usage:
9# source build/dev-shell.sh
10#
11# Notes:
12# - assumes that $REPO_ROOT is $PWD.
13# - build/py2.sh is a slimmer version, for just python2
14
15# Include guard
16test -n "${__BUILD_DEV_SHELL_SH:-}" && return
17readonly __BUILD_DEV_SHELL_SH=1
18
19# Used by BOTH this file, build/old-wedges.sh
20_MYPY_VERSION=0.780
21_PY3_LIBS_VERSION=2023-03-04
22_SITE_PACKAGES=lib/python3.10/site-packages
23
24# So we can run Python 2 scripts directly, e.g. asdl/asdl_main.py
25# Must come before old-wedges.sh
26PYTHONPATH='.'
27
28#
29# PATH for old wedges - not available in Soil CI, but are on contributor machines
30#
31
32_OLD_WEDGES=build/old-wedges.sh
33if test -f $_OLD_WEDGES; then
34 # note: 'source' doesn't work under /bin/sh
35 . $_OLD_WEDGES
36fi
37
38#
39# PATH for 2025 wedges
40#
41
42_DEPS_BIN_DIR=$PWD/../oils.DEPS/bin
43if test -d $_DEPS_BIN_DIR; then
44 PATH="$_DEPS_BIN_DIR:$PATH"
45fi
46
47#
48# R_LIBS_USER
49#
50
51_NEW_WEDGE_DIR=$PWD/../oils.DEPS/wedge
52if test -d $_NEW_WEDGE_DIR/R-libs; then
53 R_LIBS_USER=$_NEW_WEDGE_DIR/R-libs/2023-04-18
54fi
55
56#
57# PYTHONPATH
58#
59
60# Unconditionally add to PYTHONPATH, to avoid ordering issues in initial build/deps.sh setup
61readonly _NEW_PY3_LIBS_WEDGE=$_NEW_WEDGE_DIR/py3-libs/$_PY3_LIBS_VERSION/$_SITE_PACKAGES
62PYTHONPATH="$_NEW_PY3_LIBS_WEDGE:$PYTHONPATH"
63
64readonly _NEW_MYPY_WEDGE=$_NEW_WEDGE_DIR/mypy/$_MYPY_VERSION
65if test -d "$_NEW_MYPY_WEDGE"; then
66 PYTHONPATH="$_NEW_MYPY_WEDGE:$PYTHONPATH"
67fi
68
69# Hack for misconfigured RC cluster! Some machines have the empty string in
70# their $PATH (due to some having CUDA and others not).
71#
72# TODO: I should fix the machines, and make this a FATAL error. The $PATH
73# leaks on purpose because we might want to run with nix-shell -- see
74# test/spec-common.sh.
75case $PATH in
76 *::*)
77 PATH=$(echo "$PATH" | sed 's/::/:/g')
78 ;;
79esac
80
81#
82# Export all vars MUTATED
83#
84
85# Some of them might be exported already, but that's OK
86export PATH PYTHONPATH R_LIBS_USER