-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (195 loc) · 9.24 KB
/
build-glibc236.yml
File metadata and controls
230 lines (195 loc) · 9.24 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
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 \
dpkg-deb \
fakeroot
- 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 deb package
run: |
PACKAGE_NAME="python-${{ github.event.inputs.python_version }}-linux-glibc236-$(uname -m)"
PY_VERSION="${{ github.event.inputs.python_version }}"
PY_MAJOR_MINOR=$(echo $PY_VERSION | cut -d. -f1,2)
# Create deb package structure
mkdir -p deb_package/DEBIAN
mkdir -p deb_package/opt/python-$PY_VERSION-glibc236
# Copy Python installation to deb package structure
cp -r python_install/* deb_package/opt/python-$PY_VERSION-glibc236/
# Create DEBIAN control file
INSTALLED_SIZE=$(du -sk deb_package/opt | cut -f1)
echo "Package: python${PY_MAJOR_MINOR}-custom-glibc236" > deb_package/DEBIAN/control
echo "Version: $PY_VERSION" >> deb_package/DEBIAN/control
echo "Section: interpreters" >> deb_package/DEBIAN/control
echo "Priority: optional" >> deb_package/DEBIAN/control
echo "Architecture: amd64" >> deb_package/DEBIAN/control
echo "Installed-Size: $INSTALLED_SIZE" >> deb_package/DEBIAN/control
echo "Depends: libc6 (>= 2.17), libssl3 | libssl1.1 | libssl1.0.0, zlib1g, libbz2-1.0, libffi8 | libffi7 | libffi6, libgdbm6 | libgdbm5 | libgdbm3, liblzma5, libncurses6 | libncurses5, libreadline8 | libreadline7 | libreadline6, libsqlite3-0, uuid-runtime" >> deb_package/DEBIAN/control
echo "Maintainer: anubhavkrishna1 <[email protected]>" >> deb_package/DEBIAN/control
echo "Description: Custom Python $PY_VERSION interpreter (glibc 2.36 compatible)" >> deb_package/DEBIAN/control
echo " This package provides a custom-built Python $PY_VERSION interpreter" >> deb_package/DEBIAN/control
echo " with optimizations enabled and built for glibc 2.36 compatibility." >> deb_package/DEBIAN/control
echo " Built from source with LTO and PGO optimizations for better performance" >> deb_package/DEBIAN/control
echo " while maintaining compatibility with older Linux distributions." >> deb_package/DEBIAN/control
echo " ." >> deb_package/DEBIAN/control
echo " The Python installation is located in /opt/python-$PY_VERSION-glibc236/" >> deb_package/DEBIAN/control
echo " and includes pip, setuptools, and wheel." >> deb_package/DEBIAN/control
# Build deb package
fakeroot dpkg-deb --build deb_package $PACKAGE_NAME.deb
- name: Create checksum file
run: |
sha256sum ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }}.deb > 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
**Available Formats:**
- `.tar.gz` - Extract to any directory
- `.zip` - Extract to any directory
- `.deb` - Debian/Ubuntu package (installs to /opt/python-${{ github.event.inputs.python_version }}-glibc236/)
**Installation:**
- **Debian/Ubuntu**: `sudo dpkg -i ${{ env.PACKAGE_NAME }}.deb`
- **Manual**: Extract tar.gz or zip to desired location
draft: false
prerelease: false
files: |
${{ env.PACKAGE_NAME }}.tar.gz
${{ env.PACKAGE_NAME }}.zip
${{ env.PACKAGE_NAME }}.deb
SHA256SUMS.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}