Last active
January 29, 2020 17:16
-
-
Save tonejito/f9deca4b7d9f09797061023099f72abf to your computer and use it in GitHub Desktop.
Compile @python 3.x for older systems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL=/bin/bash | |
# = ^ . ^ = | |
APT_OPTS=-q=2 --assume-yes | |
APT_DEPS=build-essential \ | |
tcl-dev tk-dev \ | |
libpq-dev libffi-dev zlib1g-dev libreadline-dev libbz2-dev libncurses-dev libdbm-ocaml-dev libgdbm-dev liblzma-dev libsqlite3-dev uuid-dev libxml2-dev libxslt-dev \ | |
libssl-dev openssl \ | |
python3-pip python3-dev | |
VERSION=3.7 | |
FULL_VERSION=${VERSION}.6 | |
PKG=Python-${FULL_VERSION} | |
PKG_URL=https://www.python.org/ftp/python/${FULL_VERSION}/${PKG}.tgz | |
PREFIX=/usr/local | |
CONFIGURE_OPTS=--enable-shared --disable-profiling | |
all: ${PKG}.tgz ${PKG} build | |
everything: apt all install ldconfig check | |
clean: ${PKG} | |
$(MAKE) clean -C ${PKG} | |
dist-clean: | |
rm -rf *.deb ${PKG}.tgz ${PKG} || true | |
# Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host(). | |
# Ubuntu Trusty OpenSSL version does not have it but xenial does! | |
# Thus we upgrade libssl only! | |
apt: | |
printf "%s\n%s\n" 'DPkg::Progress-Fancy "1";' 'APT::Color "1";' | \ | |
sudo tee /etc/apt/apt.conf.d/99local | |
sudo apt ${APT_OPTS} update | |
sudo apt ${APT_OPTS} install ${APT_DEPS} | |
for PKG in libssl1.0.0_1.0.2g-1ubuntu4.15_amd64.deb libssl-dev_1.0.2g-1ubuntu4.15_amd64.deb ; \ | |
do \ | |
wget -c -nv "http://security.ubuntu.com/ubuntu/pool/main/o/openssl/$$PKG" ; \ | |
DEBIAN_FRONTEND=noninteractive dpkg -i $$PKG ; \ | |
dpkg-deb -c $$PKG ; \ | |
done | |
file -s /usr/lib/x86_64-linux-gnu/libcrypto.* /usr/lib/x86_64-linux-gnu/libssl.* /usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/* | |
${PKG}.tgz: | |
wget -c -nv ${PKG_URL} | |
${PKG}: ${PKG}.tgz | |
tar -xvvzf ${PKG}.tgz | |
build: ${PKG}/python | |
${PKG}/python: ${PKG} | |
cd ${PKG} && \ | |
./configure --prefix=${PREFIX} ${CONFIGURE_OPTS} && \ | |
make | |
install: | |
cd ${PKG} && \ | |
sudo -H make altinstall | |
sudo -H pip3.7 install --upgrade pip | |
ldconfig: | |
echo ${PREFIX}/lib | sudo tee -a /etc/ld.so.conf.d/python${VERSION}.conf | |
sudo ldconfig | |
check: | |
openssl version | |
which python${VERSION} | |
which python${VERSION} | xargs -r -t ldd | |
env python${VERSION} --version | |
python${VERSION} --version | |
vagrant: | |
$@ halt | |
$@ destroy -f | |
$@ up --provision | |
$@ ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment