2021-05-26 20:02:47 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#
|
|
|
|
# Configure, build and install python
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# build-and-install-python.sh [-version 3.9.5]
|
2021-06-24 22:57:41 +02:00
|
|
|
# needed packages : libncurses5-dev libgdbm-dev libnss3-dev
|
|
|
|
# libssl-dev libsqlite3-dev libreadline-dev libffi-dev libbz2-dev
|
2021-05-26 20:02:47 +02:00
|
|
|
|
|
|
|
PYTHON_VERSION=3.9.5
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
-version|-v)
|
|
|
|
PYTHON_VERSION=$2
|
|
|
|
shift
|
|
|
|
;;&
|
|
|
|
*)
|
|
|
|
echo "Usage: Usage: ${0##*/} [-version 3.9.5]"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Download
|
2021-08-08 20:45:36 +02:00
|
|
|
wget "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz"
|
|
|
|
tar xvf "Python-${PYTHON_VERSION}.tgz"
|
2021-05-26 20:02:47 +02:00
|
|
|
# Configure, build and install
|
2021-08-08 20:45:36 +02:00
|
|
|
cd "Python-${PYTHON_VERSION}" || exit 1
|
2021-05-26 20:02:47 +02:00
|
|
|
# Disable --enable-shared --enable-optimizations --prefix=/usr/local/python-${PYTHON_VERSION}
|
|
|
|
./configure --with-ensurepip=install
|
2021-08-08 20:45:36 +02:00
|
|
|
make -j"$(nproc) "
|
2021-05-26 20:02:47 +02:00
|
|
|
make install #altinstall
|
|
|
|
|
|
|
|
ln -s /usr/local/bin/python3 /usr/local/bin/python
|
|
|
|
ln -s /usr/local/bin/pip3 /usr/local/bin/pip
|
|
|
|
|
|
|
|
# Clean
|
|
|
|
cd ..
|
2021-08-08 20:45:36 +02:00
|
|
|
rm -rf "Python-${PYTHON_VERSION}"
|