-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_python.sh
More file actions
executable file
·100 lines (94 loc) · 1.98 KB
/
Copy pathupdate_python.sh
File metadata and controls
executable file
·100 lines (94 loc) · 1.98 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /bin/bash
echo "This script updates python"
if [ -z "$1" ];
then
echo "Use $0 download-url | downloaded_file"
echo "\te.g. $0 https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz"
echo "\te.g. $0 3.11.1"
exit 1
fi
if [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
url="https://www.python.org/ftp/python/$1/Python-$1.tar.xz"
elif [ -f "$1" ];
then
zipped="$1"
else
url="$1"
fi
if [ -z "$zipped" ];
then
cd ${TMPDIR:-/tmp}
if ! wget -c "$url";
then
echo "Error downloading $url"
exit 1
fi
zipped=$(basename "$url")
if [ ! -f $zipped ];
then
echo "Error: downloaded file not found $zipped"
exit 1
fi
fi
echo "zipped $zipped"
if [[ "$zipped" == *.tar.gz ]];
then
foldername=$(basename "$zipped" .tar.gz)
taroption=xzvf
elif [[ "$zipped" == *.tgz ]];
then
foldername=$(basename "$zipped" .tgz)
taroption=xzvf
elif [[ "$zipped" == *.tar.xz ]];
then
foldername=$(basename "$zipped" .tar.xz)
taroption=xJvf
else
echo "Not prepared for this kind of file: $zipped"
exit 1
fi
echo "foldername $foldername"
if [ ! -d $foldername ];
then
tar $taroption "$zipped"
fi
if [ ! -d $foldername ];
then
echo "Error: expected folder name $foldername"
exit 1
fi
cd $foldername
if [ ! -f configure ];
then
echo "Error: expected file $foldername/configure"
exit 1
fi
# Ensure dependencies
sudo apt install -y \
build-essential \
pkg-config \
libffi-dev \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
liblzma-dev \
libgdbm-dev \
libgdbm-compat-dev \
libnss3-dev \
libedit-dev \
uuid-dev \
libyaml-dev
# Do compile
./configure --enable-optimizations --with-lto=full \
--enable-shared --with-system-libffi \
--with-ensurepip=upgrade && \
make -j $(nproc) && \
sudo make altinstall