Skip to content

Instantly share code, notes, and snippets.

@Chaz6
Created April 14, 2024 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chaz6/3944c42ef4466fb24c370c76342eb6e5 to your computer and use it in GitHub Desktop.
Save Chaz6/3944c42ef4466fb24c370c76342eb6e5 to your computer and use it in GitHub Desktop.
build-python-on-almalinux.bash
#!/usr/bin/bash
PYTHON_VERSION=3.13.0
BETA_VERSION=a6
INSTALLDIR="${HOME}"/.local/local
cd /tmp &&
wget -4 "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
echo "Extracting archive..." &&
tar xvf "Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
echo "Building Python..." &&
(cd "Python-${PYTHON_VERSION}${BETA_VERSION}" &&
CPPFLAGS="-march=native" \
LDFLAGS="-Wl,-rpath,'${INSTALLDIR}/python-'${PYTHON_VERSION}${BETA_VERSION}'/lib' -Wl,--enable-new-dtags" \
LLVM_PROFDATA=/usr/bin/llvm-profdata \
CC=/usr/bin/clang \
CXX=/usr/bin/clang++ \
./configure \
--prefix=/home/chaz/.local/local/python-"${PYTHON_VERSION}${BETA_VERSION}" \
--enable-optimizations \
--enable-shared \
--enable-loadable-sqlite-extensions &&
make -j4 && make install) &&
echo "Creating archive..." &&
([ ! -d "${INSTALLDIR}" ] && mkdir -p "${INSTALLDIR}"; cd "${INSTALLDIR}" &&
tar Jcvf "python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" "python-${PYTHON_VERSION}${BETA_VERSION}") &&
echo "Deleting build files..." &&
rm -rf "Python-${PYTHON_VERSION}${BETA_VERSION}" "Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
echo "Successful!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment