OILS / build / dev-shell.sh View on Github | oilshell.org

153 lines, 81 significant
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
11ROOT_WEDGE_DIR=/wedge/oils-for-unix.org
12# Also in build/deps.sh
13USER_WEDGE_DIR=~/wedge/oils-for-unix.org
14
15# put 'python2' in $PATH
16readonly WEDGE_PY2_DIR=$ROOT_WEDGE_DIR/pkg/python2/2.7.18/bin
17if test -d $WEDGE_PY2_DIR; then
18 export PATH="$WEDGE_PY2_DIR:$PATH"
19fi
20
21# put 'python3' in $PATH
22readonly 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
25export PATH="$WEDGE_PY3_DIR:$PATH"
26
27readonly WEDGE_BLOATY_DIR=$ROOT_WEDGE_DIR/pkg/bloaty/1.1 # not in bin
28if test -d $WEDGE_BLOATY_DIR; then
29 export PATH="$WEDGE_BLOATY_DIR:$PATH"
30fi
31
32readonly WEDGE_RE2C_DIR=$ROOT_WEDGE_DIR/pkg/re2c/3.0/bin
33if test -d $WEDGE_RE2C_DIR; then
34 export PATH="$WEDGE_RE2C_DIR:$PATH"
35fi
36
37# uftrace must be installed by wedge?
38readonly UFTRACE_WEDGE_DIR=$ROOT_WEDGE_DIR/pkg/uftrace/0.13/bin
39if test -d $UFTRACE_WEDGE_DIR; then
40 export PATH="$UFTRACE_WEDGE_DIR:$PATH"
41fi
42
43# FALLBACK without busybox wedge: test/spec.sh link-busybox-ash
44readonly ASH_SYMLINK_DIR="$PWD/_tmp/shells"
45if test -d $ASH_SYMLINK_DIR; then
46 export PATH="$ASH_SYMLINK_DIR:$PATH"
47fi
48
49readonly WEDGE_SOUFFLE_DIR=$USER_WEDGE_DIR/pkg/souffle/2.4.1/bin
50if test -d $WEDGE_SOUFFLE_DIR; then
51 export PATH="$WEDGE_SOUFFLE_DIR:$PATH"
52fi
53
54# test/spec-bin.sh builds binaries
55# This takes precedence over $ASH_SYMLINK_DIR
56readonly SPEC_DIR="$PWD/../oil_DEPS/spec-bin"
57
58if test -d $SPEC_DIR; then
59 export PATH="$SPEC_DIR:$PATH"
60fi
61
62#
63# NEW spec-bin wedges found before old ../oil_DEPS
64#
65
66readonly BASH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/bash/4.4/bin
67if test -d $BASH_WEDGE_DIR; then
68 export PATH="$BASH_WEDGE_DIR:$PATH"
69fi
70
71# bash 5 found before bash 4
72readonly BASH5_WEDGE_DIR=$USER_WEDGE_DIR/pkg/bash/5.2.21/bin
73if test -d $BASH5_WEDGE_DIR; then
74 export PATH="$BASH5_WEDGE_DIR:$PATH"
75fi
76
77readonly DASH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/dash/0.5.10.2/bin
78if test -d $DASH_WEDGE_DIR; then
79 export PATH="$DASH_WEDGE_DIR:$PATH"
80fi
81
82readonly MKSH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/mksh/R52c
83if test -d $MKSH_WEDGE_DIR; then
84 export PATH="$MKSH_WEDGE_DIR:$PATH"
85fi
86
87readonly ZSH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/zsh/5.1.1/bin
88if test -d $ZSH_WEDGE_DIR; then
89 export PATH="$ZSH_WEDGE_DIR:$PATH"
90fi
91
92readonly BUSYBOX_WEDGE_DIR=$USER_WEDGE_DIR/pkg/busybox/1.35.0
93if test -d $BUSYBOX_WEDGE_DIR; then
94 export PATH="$BUSYBOX_WEDGE_DIR:$PATH"
95fi
96
97readonly YASH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/yash/2.49/bin
98if test -d $YASH_WEDGE_DIR; then
99 export PATH="$YASH_WEDGE_DIR:$PATH"
100fi
101
102if test -d ~/R; then
103 # 2023-07: Hack to keep using old versions on lenny.local
104 # In 2023-04, dplyr stopped supporting R 3.4.4 on Ubuntu Bionic
105 # https://cran.r-project.org/web/packages/dplyr/index.html
106 export R_LIBS_USER=~/R
107else
108 R_LIBS_WEDGE=~/wedge/oils-for-unix.org/pkg/R-libs/2023-04-18
109 export R_LIBS_USER=$R_LIBS_WEDGE
110fi
111
112# So we can run Python 2 scripts directly, e.g. asdl/asdl_main.py
113export PYTHONPATH='.'
114
115# We can also run mycpp/mycpp_main.py directly
116#
117# But NOT bin/oils_for_unix.py (Python 2). Those need to find our stripped down
118# vendor/typing.py, but we CANNOT put vendor/ in $PYTHONPATH, because then
119# mycpp would import it and fail.
120
121readonly site_packages=lib/python3.10/site-packages
122
123#readonly PY3_LIBS_VERSION=2023-07-27
124# Use older version because containers aren't rebuild. TODO: fix this
125readonly PY3_LIBS_VERSION=2023-03-04
126
127# Note: Version should match the one in build/deps.sh
128readonly PY3_LIBS_WEDGE=$USER_WEDGE_DIR/pkg/py3-libs/$PY3_LIBS_VERSION/$site_packages
129# Unconditionally add to PYTHONPATH; otherwise build/deps.sh install-wedges
130# can't work in one shot
131export PYTHONPATH="$PY3_LIBS_WEDGE:$PYTHONPATH"
132
133MYPY_VERSION=0.780
134# TODO: would be nice to upgrade to newer version
135#readonly MYPY_VERSION=0.971
136
137# Containers copy it here
138readonly MYPY_WEDGE=$USER_WEDGE_DIR/pkg/mypy/$MYPY_VERSION
139if test -d "$MYPY_WEDGE"; then
140 export PYTHONPATH="$MYPY_WEDGE:$PYTHONPATH"
141fi
142
143# Hack for misconfigured RC cluster! Some machines have the empty string in
144# their $PATH (due to some having CUDA and others not).
145#
146# TODO: I should fix the machines, and make this a FATAL error. The $PATH
147# leaks on purpose because we might want to run with nix-shell -- see
148# test/spec-common.sh.
149case $PATH in
150 *::*)
151 PATH=$(echo "$PATH" | sed 's/::/:/g')
152 ;;
153esac