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

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