-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_python.sh
executable file
·52 lines (44 loc) · 1.64 KB
/
setup_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
#!/bin/bash
if [ $# -le 1 ]; then
echo "This is $(basename $0). Usage:"
echo "$(basename $0) [version] [/path/to/install/parent/directory] [python configure flags]"
echo "Example:"
echo "$(basename $0) 3.7.4 $HOME/.bazel_python --enable-optimizations"
exit 1
fi
version=$1
shift
install_parent_dir=$1
shift
install_dir=$install_parent_dir/$version
read -p "Installing Python $1. This will *OVERWRITE* $install_dir. Continue? [y/N] " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf $install_dir
mkdir -p $install_dir
cd $install_dir
curl -OL https://www.python.org/ftp/python/$version/Python-$version.tgz
tar -xzf Python-$version.tgz
cd Python-$version
./configure --prefix=$install_dir $@
make -j
make install
cd $install_dir
rm -rf Python-$version
rm -rf Python-$version.tgz
echo "Success!"
echo "Writing Installation Directory to $HOME/.bazelrc"
echo "If you have run this script multiple times, you may safely remove duplicate lines from $HOME/.bazelrc"
echo "build --define BAZEL_PYTHON_DIR=$install_parent_dir" >> $HOME/.bazelrc
echo "run --define BAZEL_PYTHON_DIR=$install_parent_dir" >> $HOME/.bazelrc
if ! $install_dir/bin/python3 -c "import ssl"
then
echo "WARNING: Python was built *WITHOUT* the SSL module. This will break PyPI downloads. Please re-run this script after installing libssl-dev (see the README)."
fi
if ! $install_dir/bin/python3 -c "import zlib"
then
echo "WARNING: Python was built *WITHOUT* the zlib module. If needed, please re-run this script after installing zlib1g-dev (see the README)."
fi
else
echo "Aborting."
fi