1 # Sets $PATH to the locations of some precompiled binaries.
2 # An alternative to nix-shell.
3 #
4 # Usage:
5 # source build/dev-shell.sh
6 #
7 # Note: assumes that $REPO_ROOT is $PWD.
8 #
9 # IMPORTANT: sourced by _build/oils.sh, so it must remain POSIX SHELL
10
11 ROOT_WEDGE_DIR=/wedge/oils-for-unix.org
12 # Also in build/deps.sh
13 USER_WEDGE_DIR=~/wedge/oils-for-unix.org
14
15 # put 'python2' in $PATH
16 readonly WEDGE_PY2_DIR=$ROOT_WEDGE_DIR/pkg/python2/2.7.18/bin
17 if test -d $WEDGE_PY2_DIR; then
18 export PATH="$WEDGE_PY2_DIR:$PATH"
19 fi
20
21 # put 'python3' in $PATH
22 readonly WEDGE_PY3_DIR=$ROOT_WEDGE_DIR/pkg/python3/3.10.4/bin
23 # Unconditionally add it to PATH; otherwise build/deps.sh install-wedges won't
24 # work
25 export PATH="$WEDGE_PY3_DIR:$PATH"
26
27 readonly WEDGE_BLOATY_DIR=$ROOT_WEDGE_DIR/pkg/bloaty/1.1 # not in bin
28 if test -d $WEDGE_BLOATY_DIR; then
29 export PATH="$WEDGE_BLOATY_DIR:$PATH"
30 fi
31
32 readonly WEDGE_RE2C_DIR=$ROOT_WEDGE_DIR/pkg/re2c/3.0/bin
33 if test -d $WEDGE_RE2C_DIR; then
34 export PATH="$WEDGE_RE2C_DIR:$PATH"
35 fi
36
37 # uftrace must be installed by wedge?
38 readonly UFTRACE_WEDGE_DIR=$ROOT_WEDGE_DIR/pkg/uftrace/0.13/bin
39 if test -d $UFTRACE_WEDGE_DIR; then
40 export PATH="$UFTRACE_WEDGE_DIR:$PATH"
41 fi
42
43 # FALLBACK without test/spec-bin: test/spec.sh link-busybox-ash
44 readonly ASH_SYMLINK_DIR="$PWD/_tmp/shells"
45 if test -d $ASH_SYMLINK_DIR; then
46 export PATH="$ASH_SYMLINK_DIR:$PATH"
47 fi
48
49 # test/spec-bin.sh builds binaries
50 # This takes precedence over $ASH_SYMLINK_DIR
51 readonly SPEC_DIR="$PWD/../oil_DEPS/spec-bin"
52
53 if test -d $SPEC_DIR; then
54 export PATH="$SPEC_DIR:$PATH"
55 fi
56
57 if test -d ~/R; then
58 # 2023-07: Hack to keep using old versions on lenny.local
59 # In 2023-04, dplyr stopped supporting R 3.4.4 on Ubuntu Bionic
60 # https://cran.r-project.org/web/packages/dplyr/index.html
61 export R_LIBS_USER=~/R
62 else
63 R_LIBS_WEDGE=~/wedge/oils-for-unix.org/pkg/R-libs/2023-04-18
64 export R_LIBS_USER=$R_LIBS_WEDGE
65 fi
66
67 # So we can run Python 2 scripts directly, e.g. asdl/asdl_main.py
68 export PYTHONPATH='.'
69
70 # We can also run mycpp/mycpp_main.py directly
71 #
72 # But NOT bin/oils_for_unix.py (Python 2). Those need to find our stripped down
73 # vendor/typing.py, but we CANNOT put vendor/ in $PYTHONPATH, because then
74 # mycpp would import it and fail.
75
76 readonly site_packages=lib/python3.10/site-packages
77
78 #readonly PY3_LIBS_VERSION=2023-07-27
79 # Use older version because containers aren't rebuild. TODO: fix this
80 readonly PY3_LIBS_VERSION=2023-03-04
81
82 # Note: Version should match the one in build/deps.sh
83 readonly PY3_LIBS_WEDGE=$USER_WEDGE_DIR/pkg/py3-libs/$PY3_LIBS_VERSION/$site_packages
84 # Unconditionally add to PYTHONPATH; otherwise build/deps.sh install-wedges
85 # can't work in one shot
86 export PYTHONPATH="$PY3_LIBS_WEDGE:$PYTHONPATH"
87
88 MYPY_VERSION=0.780
89 # TODO: would be nice to upgrade to newer version
90 #readonly MYPY_VERSION=0.971
91
92 # Containers copy it here
93 readonly MYPY_WEDGE=$USER_WEDGE_DIR/pkg/mypy/$MYPY_VERSION
94 if test -d "$MYPY_WEDGE"; then
95 export PYTHONPATH="$MYPY_WEDGE:$PYTHONPATH"
96 fi
97
98 # Hack for misconfigured RC cluster! Some machines have the empty string in
99 # their $PATH (due to some having CUDA and others not).
100 #
101 # TODO: I should fix the machines, and make this a FATAL error. The $PATH
102 # leaks on purpose because we might want to run with nix-shell -- see
103 # test/spec-common.sh.
104 case $PATH in
105 *::*)
106 PATH=$(echo "$PATH" | sed 's/::/:/g')
107 ;;
108 esac