|
| 1 | +name: Build Python Binary with glibc 2.36 |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + python_version: |
| 7 | + description: 'Python version to build (e.g., 3.9.18, 3.10.13, 3.11.7)' |
| 8 | + required: true |
| 9 | + default: '3.11.7' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-python-glibc236: |
| 13 | + runs-on: ubuntu-20.04 # Using Ubuntu 20.04 for older glibc |
| 14 | + container: |
| 15 | + image: ubuntu:18.04 # Even older Ubuntu for glibc 2.36 compatibility |
| 16 | + steps: |
| 17 | + - name: Install basic tools |
| 18 | + run: | |
| 19 | + apt-get update |
| 20 | + apt-get install -y ca-certificates curl wget git |
| 21 | + |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Set architecture and build date |
| 26 | + run: | |
| 27 | + echo "RELEASE_TAG=python-${{ github.event.inputs.python_version }}-linux-glibc236" >> $GITHUB_ENV |
| 28 | + echo "BUILD_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 29 | + echo "ARCHITECTURE=$(uname -m)" >> $GITHUB_ENV |
| 30 | + echo "GLIBC_VERSION=$(ldd --version | head -n1 | grep -o '[0-9]\+\.[0-9]\+')" >> $GITHUB_ENV |
| 31 | + |
| 32 | + - name: Install build dependencies |
| 33 | + run: | |
| 34 | + apt-get update |
| 35 | + apt-get install -y \ |
| 36 | + build-essential \ |
| 37 | + gdb \ |
| 38 | + lcov \ |
| 39 | + pkg-config \ |
| 40 | + libbz2-dev \ |
| 41 | + libffi-dev \ |
| 42 | + libgdbm-dev \ |
| 43 | + libgdbm-compat-dev \ |
| 44 | + liblzma-dev \ |
| 45 | + libncurses5-dev \ |
| 46 | + libreadline6-dev \ |
| 47 | + libsqlite3-dev \ |
| 48 | + libssl-dev \ |
| 49 | + lzma \ |
| 50 | + lzma-dev \ |
| 51 | + tk-dev \ |
| 52 | + uuid-dev \ |
| 53 | + zlib1g-dev \ |
| 54 | + wget \ |
| 55 | + curl \ |
| 56 | + llvm \ |
| 57 | + make \ |
| 58 | + xz-utils |
| 59 | +
|
| 60 | + - name: Download Python source |
| 61 | + run: | |
| 62 | + wget https://www.python.org/ftp/python/${{ github.event.inputs.python_version }}/Python-${{ github.event.inputs.python_version }}.tgz |
| 63 | + tar xzf Python-${{ github.event.inputs.python_version }}.tgz |
| 64 | + |
| 65 | + - name: Prepare build directory |
| 66 | + run: | |
| 67 | + mkdir -p python_install |
| 68 | + INSTALL_PATH=$(pwd)/python_install |
| 69 | + echo "INSTALL_PATH=$INSTALL_PATH" >> $GITHUB_ENV |
| 70 | +
|
| 71 | + - name: Configure and build Python |
| 72 | + run: | |
| 73 | + cd Python-${{ github.event.inputs.python_version }} |
| 74 | + |
| 75 | + # Set optimization flags for glibc 2.36 compatibility |
| 76 | + OPT_FLAGS="--enable-optimizations --with-lto" |
| 77 | + |
| 78 | + # Additional flags for better compatibility with older systems |
| 79 | + COMPAT_FLAGS="--enable-shared --with-system-ffi --with-computed-gotos" |
| 80 | + |
| 81 | + # Configure Python build |
| 82 | + INSTALL_PATH=$(pwd)/../python_install |
| 83 | + ./configure \ |
| 84 | + --prefix=$INSTALL_PATH \ |
| 85 | + $OPT_FLAGS \ |
| 86 | + $COMPAT_FLAGS \ |
| 87 | + --enable-loadable-sqlite-extensions \ |
| 88 | + --with-dbmliborder=bdb:gdbm \ |
| 89 | + --with-ssl-default-suites=openssl |
| 90 | + |
| 91 | + # Build and install |
| 92 | + make -j$(nproc) |
| 93 | + make install |
| 94 | +
|
| 95 | + # Fix any remaining shebang issues |
| 96 | + PY_VERSION=$(echo ${{ github.event.inputs.python_version }} | cut -d. -f1,2) |
| 97 | + find "$INSTALL_PATH/bin" -type f -not -name "python*" -exec sed -i '1s|^#!.*/bin/python[0-9.]*|#!/usr/bin/env python'$PY_VERSION'|' {} \; |
| 98 | +
|
| 99 | + - name: Verify glibc compatibility |
| 100 | + run: | |
| 101 | + echo "Checking glibc dependencies:" |
| 102 | + find python_install -name "*.so*" -exec ldd {} \; | grep libc.so | sort -u |
| 103 | + echo "Python executable glibc dependencies:" |
| 104 | + ldd python_install/bin/python* | grep libc.so |
| 105 | +
|
| 106 | + - name: Test Python installation |
| 107 | + run: | |
| 108 | + export LD_LIBRARY_PATH=$PWD/python_install/lib:$LD_LIBRARY_PATH |
| 109 | + python_install/bin/python3 --version |
| 110 | + python_install/bin/python3 -c "import sys; print(f'Python {sys.version}')" |
| 111 | + python_install/bin/python3 -c "import ssl; print(f'SSL support: {ssl.OPENSSL_VERSION}')" |
| 112 | + python_install/bin/pip3 --version |
| 113 | +
|
| 114 | + - name: Remove unnecessary files |
| 115 | + run: | |
| 116 | + # Remove tests |
| 117 | + find python_install -type d -name "test" -o -name "tests" | xargs rm -rf 2>/dev/null || true |
| 118 | + find python_install -type d -name "__pycache__" | xargs rm -rf 2>/dev/null || true |
| 119 | +
|
| 120 | + # Remove idle and other GUI tools if not needed |
| 121 | + rm -f python_install/bin/idle* 2>/dev/null || true |
| 122 | + |
| 123 | + # Remove static libraries to reduce size |
| 124 | + find python_install -name "*.a" -delete 2>/dev/null || true |
| 125 | +
|
| 126 | + - name: Create binary archives |
| 127 | + run: | |
| 128 | + PACKAGE_NAME="python-${{ github.event.inputs.python_version }}-linux-glibc236-$(uname -m)" |
| 129 | + |
| 130 | + # Create tarball |
| 131 | + tar -czvf $PACKAGE_NAME.tar.gz -C python_install . |
| 132 | + |
| 133 | + # Create zip file |
| 134 | + cd python_install |
| 135 | + zip -r ../$PACKAGE_NAME.zip . |
| 136 | + cd .. |
| 137 | + |
| 138 | + echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV |
| 139 | + |
| 140 | + - name: Create checksum file |
| 141 | + run: | |
| 142 | + sha256sum ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}.zip > SHA256SUMS.txt |
| 143 | + |
| 144 | + - name: Create Release |
| 145 | + id: create_release |
| 146 | + uses: softprops/action-gh-release@v1 |
| 147 | + with: |
| 148 | + tag_name: ${{ env.RELEASE_TAG }} |
| 149 | + name: Python ${{ github.event.inputs.python_version }} Linux Binary (glibc 2.36) |
| 150 | + body: | |
| 151 | + Custom Python ${{ github.event.inputs.python_version }} binary build for Linux with glibc 2.36 compatibility |
| 152 | + |
| 153 | + **Build Configuration:** |
| 154 | + - Python Version: ${{ github.event.inputs.python_version }} |
| 155 | + - glibc Version: ${{ env.GLIBC_VERSION }} |
| 156 | + - Optimization Level: 2 (full optimizations with LTO) |
| 157 | + - With Pip/Setuptools/Wheel: Yes |
| 158 | + - Architecture: ${{ env.ARCHITECTURE }} |
| 159 | + - Build Date: ${{ env.BUILD_DATE }} |
| 160 | + - Built by: anubhavkrishna1 |
| 161 | + - Container: Ubuntu 18.04 for maximum compatibility |
| 162 | + |
| 163 | + **Features:** |
| 164 | + - Compatible with older Linux distributions (glibc 2.36+) |
| 165 | + - Shared libraries enabled for better compatibility |
| 166 | + - SSL/TLS support included |
| 167 | + - SQLite extensions support |
| 168 | + - Optimized with LTO and PGO |
| 169 | + |
| 170 | + **Installation:** |
| 171 | + 1. Download the tar.gz file |
| 172 | + 2. Download and run the install.sh script: `bash install.sh [install_path]` |
| 173 | + 3. Or extract manually: `tar -xzf ${{ env.PACKAGE_NAME }}.tar.gz -C /your/install/path` |
| 174 | + |
| 175 | + draft: false |
| 176 | + prerelease: false |
| 177 | + files: | |
| 178 | + ${{ env.PACKAGE_NAME }}.tar.gz |
| 179 | + ${{ env.PACKAGE_NAME }}.zip |
| 180 | + SHA256SUMS.txt |
| 181 | + env: |
| 182 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments