-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathupdate-python.sh
More file actions
44 lines (33 loc) · 788 Bytes
/
update-python.sh
File metadata and controls
44 lines (33 loc) · 788 Bytes
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
#!/usr/bin/env bash
set -e
set -x
NB_CORES="$(grep -c processor /proc/cpuinfo)"
install_python()
{
ver=$1
pushd .
cd /opt
curl -fsSL https://www.python.org/ftp/python/${ver}/Python-${ver}.tgz | sudo tar xfz -
cd Python-${ver}
sudo ./configure --enable-optimizations
sudo make -j ${NB_CORES}
sudo make -j ${NB_CORES} altinstall
popd
}
migrate_packages()
{
ver=$1
tmp=$(tempfile)
python -m pip freeze > ${tmp}
/opt/Python-${ver}/python -m pip install --upgrade --user setuptools wheel
/opt/Python-${ver}/python -m pip install --upgrade --user --no-color -r ${tmp}
rm -- ${tmp}
}
if [ $# -lt 1 ]
then
echo "Missing desired Python version (example: 3.8.0)"
exit 1
fi
install_python $1
migrate_packages $1
exit 0