# Python 3.9.21 (released 2024-12-03)
# =============
# See the main Python HOWTO for general information and then continue here
# for information specific to 3.9.x releases
# If you're about to upgrade from 3.8.x to 3.9.x, read this:
# What's New In Python 3.9
# for info about changes between the two versions. For more info read
# Misc/NEWS.
# Get the source tarball
cd
test -f installed/Python-3.9.21.tar.xz && mv installed/Python-3.9.21.tar.xz .
test ! -f Python-3.9.21.tar.xz &&
wget https://www.python.org/ftp/python/3.9.21/Python-3.9.21.tar.xz
# Extract it
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "Python-3.*" -exec rm -r {} \;
tar xJvf ~/Python-3.9.21.tar.xz
cd Python-3.9.21
test $UID = 0 && chown -R root:root .
# I used to apply a patch to change various things from /lib/ to /lib64/
# which configure's --libdir was not handling. Now there is a
# --with-platlibdir=lib64 that will help that, but even with that, you
# will still end up with a /usr/lib/python3.9/site-packages/
## Configure the build
# If you somehow don't need pip, leave off --with-ensurepip=install
# You could just install it later, but every way I tried to do it a while
# back with 2.x, I'd get stuck with a dependency loop between the get-pip.py
# script needing urllib3, not having it, that requires something else, ...
# If you want to enable optimizations, use ... --enable-optimizations
# If you have source-installed OpenSSL < 1.1.0 with the default prefix of
# /usr/local/ssl and are 64-bit, you may need to use this at the beginning of
# configure:
# LDFLAGS=-L/usr/local/ssl/lib64
# If you are 64-bit:
test $(uname -m) = 'x86_64' &&
./configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man \
--enable-shared --with-platlibdir=lib64 --with-ensurepip=install
# If you are not 64-bit, no need to add anything for /usr/lib:
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --enable-shared --mandir=/usr/man \
--with-ensurepip=install
# Build it
make -j $(nproc)
# Test the build (may require su/sudo)
make test
# Become root to clean up old files and to install it
su
# Remove the Slackware packages, if there are any installed:
test -x /sbin/removepkg &&
/sbin/removepkg python python3 python-demo python-pillow python-setuptools \
python-tools
# Install the new version
#
# Use 'make install' for whatever you want your default version of
# Python to be. i.e. what you get when you run 'python'.
#
# If you use 'make altinstall' instead, that will leave existing python
# and python-config (usually in /usr/bin) pointing to whatever it was
# already pointing to. In that case, you would need to run 'python3' if
# this is the only 3.x one, or 'python3.9' if there are others 3.x versions
# installed such as 3.8.x
# Install it
make install
ldconfig
# Right now if you run 'python3' or 'python3.9' you will get Python 3.9.21
# Right now if you run 'pip3' or 'pip3.9' you will get pip 3.9.21
# (if /usr/bin/pip is a script, not a symlink, should get you 3.9.21)
# If you want to ensure that running only python, python-config, pip, pydoc
# without a 3 or a 3.9, gets you 3.9.21, do the following:
# [ this will only remove existing symlinks, not scripts ]
( cd /usr/bin
test -L 2to3 && rm 2to3
test -L pip && rm pip
test -L pydoc && rm pydoc
test -L python && rm python
test -L python-config && rm python-config
test ! -e 2to3 && ln -s 2to3-3.9 2to3
test ! -e pip && ln -s pip3.9 pip
test ! -e pydoc && ln -s pydoc3.9 pydoc
test ! -e python && ln -s python3.9 python
test ! -e python-config && ln -s python3.9-config python-config )
# If your python3, python3-config, pip3, pydoc3 symlinks need to be updated
# (probably not):
( cd /usr/bin
test -L pip3 && rm pip3
test -L pydoc3 && rm pydoc3
test -L python3 && rm python3
test -L python3-config && rm python3-config
test ! -e pip3 && ln -sf pip3.9 pip3
test ! -e pydoc3 && ln -sf pydoc3.9 pydoc3
test ! -e python3 && ln -sf python3.9 python3
test ! -e python3-config && ln -sf python3.9-config python3-config )
# You should have a /usr/include/python3.9/
#
# And you should have a /usr/lib*/libpython3.9.so.1
# and a /usr/lib*/libpython3.9.so symlink pointing to libpython3.9.so.1
# and a /usr/lib*/libpython3.so
#
# And in /usr/lib*/pkgconfig/ you should have:
# python-3.9-embed.pc
# python3-embed.pc symlink pointing to python-3.9.embed.pc
# python-3.9.pc
# python3.pc symlink pointing to python-3.9.pc
#
# And you should have /usr/lib*/python3.9/
#
# And in /usr/man/man1/ you should have:
# python3.9.1 ('man python3.9')
# python3.1 symlink pointing to python3.9.1 ('man python3')
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# If you used 'make altinstall' and already had a previous version of Python
# installed, then the python and python-config symlinks should still point
# to the previous version.
# If you used the regular 'make install' and now you want 'python' and
# 'python3' to run an older one such as 3.8.x while 3.9.x is also installed,
# you may need to do something like this:
# ln -sf /usr/bin/pydoc3.8-config /usr/bin/pydoc3
# ln -sf /usr/bin/pydoc3.8-config /usr/bin/pydoc
# ln -sf /usr/bin/pip3.8 /usr/bin/pip3
# ln -sf /usr/bin/pip3.8 /usr/bin/pip
# ln -sf /usr/bin/python3.8 /usr/bin/python3
# ln -sf /usr/bin/python3.8 /usr/bin/python
# ln -sf /usr/bin/python3.8-config /usr/bin/python3-config
# ln -sf /usr/bin/python3.8-config /usr/bin/python-config
# If you want to upgrade pip, with pip, run the following:
/usr/bin/python3.9 -m pip install --upgrade pip
# Keep the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/Python-3.*.tgz installed/Python-3.*.tar.*
mv Python-3.9.21.tar.xz installed/