-
Notifications
You must be signed in to change notification settings - Fork 165
/
install_python.sh
executable file
·65 lines (50 loc) · 1.68 KB
/
install_python.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
WORKON_HOME=${WORKON_HOME:-/opt/venv}
PYTHON_VENV_PATH=${PYTHON_VENV_PATH:-${WORKON_HOME}/reticulate}
RETICULATE_MINICONDA_ENABLED=${RETICULATE_MINICONDA_ENABLED:-FALSE}
apt-get update && apt-get install -y --no-install-recommends \
git \
libpng-dev \
libpython3-dev \
python3-dev \
python3-pip \
python3-virtualenv \
python3-venv \
swig && \
rm -rf /var/lib/apt/lists/*
python3 -m pip --no-cache-dir install --upgrade \
pip \
setuptools \
virtualenv
# Some TF tools expect a "python" binary
if [ ! -e /usr/local/bin/python ]; then
ln -s $(which python3) /usr/local/bin/python
fi
mkdir -p ${WORKON_HOME}
python3 -m venv ${PYTHON_VENV_PATH}
install2.r --skipinstalled --error reticulate
## Ensure RStudio inherits this env var
echo "" >> ${R_HOME}/etc/Renviron.site
echo "WORKON_HOME=${WORKON_HOME}" >> ${R_HOME}/etc/Renviron.site
echo "RETICULATE_MINICONDA_ENABLED=${RETICULATE_MINICONDA_ENABLED}" >> ${R_HOME}/etc/Renviron.site
## symlink these so that these are available when switching to a new venv
## -f check for file, -L for link, -e for either
if [ ! -e /usr/local/bin/python ]; then
ln -s $(which python3) /usr/local/bin/python
fi
if [ ! -e /usr/local/bin/pip ]; then
ln -s ${PYTHON_VENV_PATH}/bin/pip /usr/local/bin/pip
fi
if [ ! -e /usr/local/bin/virtualenv ]; then
ln -s ${PYTHON_VENV_PATH}/bin/virtualenv /usr/local/bin/virtualenv
fi
## Allow staff-level users to modify the shared environment
chown -R :staff ${WORKON_HOME}
chmod g+wx ${WORKON_HOME}
chown :staff ${PYTHON_VENV_PATH}
## Enable pyenv
/rocker_scripts/install_pyenv.sh
# Clean up
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/downloaded_packages