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