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

147 lines, 77 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 test/spec-bin: 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 come 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
71readonly DASH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/dash/0.5.10.2/bin
72if test -d $DASH_WEDGE_DIR; then
73 export PATH="$DASH_WEDGE_DIR:$PATH"
74fi
75
76readonly MKSH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/mksh/R52c
77if test -d $MKSH_WEDGE_DIR; then
78 export PATH="$MKSH_WEDGE_DIR:$PATH"
79fi
80
81readonly ZSH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/zsh/5.1.1/bin
82if test -d $ZSH_WEDGE_DIR; then
83 export PATH="$ZSH_WEDGE_DIR:$PATH"
84fi
85
86readonly BUSYBOX_WEDGE_DIR=$USER_WEDGE_DIR/pkg/busybox/1.35.0
87if test -d $BUSYBOX_WEDGE_DIR; then
88 export PATH="$BUSYBOX_WEDGE_DIR:$PATH"
89fi
90
91readonly YASH_WEDGE_DIR=$USER_WEDGE_DIR/pkg/yash/2.49/bin
92if test -d $YASH_WEDGE_DIR; then
93 export PATH="$YASH_WEDGE_DIR:$PATH"
94fi
95
96if test -d ~/R; then
97 # 2023-07: Hack to keep using old versions on lenny.local
98 # In 2023-04, dplyr stopped supporting R 3.4.4 on Ubuntu Bionic
99 # https://cran.r-project.org/web/packages/dplyr/index.html
100 export R_LIBS_USER=~/R
101else
102 R_LIBS_WEDGE=~/wedge/oils-for-unix.org/pkg/R-libs/2023-04-18
103 export R_LIBS_USER=$R_LIBS_WEDGE
104fi
105
106# So we can run Python 2 scripts directly, e.g. asdl/asdl_main.py
107export PYTHONPATH='.'
108
109# We can also run mycpp/mycpp_main.py directly
110#
111# But NOT bin/oils_for_unix.py (Python 2). Those need to find our stripped down
112# vendor/typing.py, but we CANNOT put vendor/ in $PYTHONPATH, because then
113# mycpp would import it and fail.
114
115readonly site_packages=lib/python3.10/site-packages
116
117#readonly PY3_LIBS_VERSION=2023-07-27
118# Use older version because containers aren't rebuild. TODO: fix this
119readonly PY3_LIBS_VERSION=2023-03-04
120
121# Note: Version should match the one in build/deps.sh
122readonly PY3_LIBS_WEDGE=$USER_WEDGE_DIR/pkg/py3-libs/$PY3_LIBS_VERSION/$site_packages
123# Unconditionally add to PYTHONPATH; otherwise build/deps.sh install-wedges
124# can't work in one shot
125export PYTHONPATH="$PY3_LIBS_WEDGE:$PYTHONPATH"
126
127MYPY_VERSION=0.780
128# TODO: would be nice to upgrade to newer version
129#readonly MYPY_VERSION=0.971
130
131# Containers copy it here
132readonly MYPY_WEDGE=$USER_WEDGE_DIR/pkg/mypy/$MYPY_VERSION
133if test -d "$MYPY_WEDGE"; then
134 export PYTHONPATH="$MYPY_WEDGE:$PYTHONPATH"
135fi
136
137# Hack for misconfigured RC cluster! Some machines have the empty string in
138# their $PATH (due to some having CUDA and others not).
139#
140# TODO: I should fix the machines, and make this a FATAL error. The $PATH
141# leaks on purpose because we might want to run with nix-shell -- see
142# test/spec-common.sh.
143case $PATH in
144 *::*)
145 PATH=$(echo "$PATH" | sed 's/::/:/g')
146 ;;
147esac