Skip to content

Instantly share code, notes, and snippets.

@Chaz6
Created April 14, 2024 15:20
Show Gist options
  • Select an option

  • Save Chaz6/3944c42ef4466fb24c370c76342eb6e5 to your computer and use it in GitHub Desktop.

Select an option

Save Chaz6/3944c42ef4466fb24c370c76342eb6e5 to your computer and use it in GitHub Desktop.

Revisions

  1. Chaz6 created this gist Apr 14, 2024.
    29 changes: 29 additions & 0 deletions build-python-on-almalinux.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/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!"