Skip to content

Commit 3a1873d

Browse files
Update build.yml
1 parent 82a7886 commit 3a1873d

1 file changed

Lines changed: 23 additions & 72 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
python_version:
77
description: 'Python version to build (e.g., 3.9.18, 3.10.13, 3.11.7)'
88
required: true
9-
default: '3.11.12'
9+
default: '3.11.7'
1010

1111
jobs:
1212
build-python:
@@ -15,17 +15,19 @@ jobs:
1515
- name: Checkout repository
1616
uses: actions/checkout@v3
1717

18-
- name: Set release tag
18+
- name: Set release tag and build date
1919
run: |
2020
echo "RELEASE_TAG=python-${{ github.event.inputs.python_version }}-linux" >> $GITHUB_ENV
21+
echo "RELEASE_TAG=python-${{ github.event.inputs.python_version }}-linux" >> $GITHUB_ENV
2122
2223
- name: Install build dependencies
2324
run: |
2425
sudo apt-get update
25-
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
26-
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
27-
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \
28-
libgdbm-dev libgdbm-compat-dev uuid-dev
26+
sudo apt-get install -y build-essential gdb lcov pkg-config \
27+
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
28+
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
29+
lzma lzma-dev tk-dev uuid-dev zlib1g-dev libmpdec-dev \
30+
wget curl llvm make
2931
3032
- name: Download Python source
3133
run: |
@@ -52,6 +54,19 @@ jobs:
5254
make -j$(nproc)
5355
make install
5456
57+
# Fix any remaining shebang issues
58+
PY_VERSION=$(echo ${{ github.event.inputs.python_version }} | cut -d. -f1,2)
59+
find "$INSTALL_DIR/bin" -type f -not -name "python*" -exec sed -i '1s|^#!.*/bin/python[0-9.]*|#!/usr/bin/env python'$PY_VERSION'|' {} \;
60+
61+
- name: Remove unnecessary files
62+
run: |
63+
# Remove tests
64+
find python_install -type d -name "test" -o -name "tests" | xargs rm -rf
65+
find python_install -type d -name "__pycache__" | xargs rm -rf
66+
67+
# Remove idle and other GUI tools if not needed
68+
rm -f python_install/bin/idle*
69+
5570
- name: Create binary archives
5671
run: |
5772
PACKAGE_NAME="python-${{ github.event.inputs.python_version }}-linux-$(uname -m)"
@@ -66,52 +81,9 @@ jobs:
6681
6782
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
6883
69-
- name: Create installation script
70-
run: |
71-
cat > install.sh << 'EOF'
72-
#!/bin/bash
73-
# Python binary installation script
74-
75-
# Default installation directory
76-
DEFAULT_INSTALL_DIR="/opt/python-${{ github.event.inputs.python_version }}"
77-
INSTALL_DIR=${1:-$DEFAULT_INSTALL_DIR}
78-
79-
# Check if run as root
80-
if [ "$(id -u)" -ne 0 ]; then
81-
echo "This script must be run as root to install to system directories."
82-
echo "Usage: sudo ./install.sh [INSTALL_DIR]"
83-
exit 1
84-
fi
85-
86-
echo "Installing Python ${{ github.event.inputs.python_version }} to $INSTALL_DIR..."
87-
88-
# Create installation directory
89-
mkdir -p "$INSTALL_DIR"
90-
91-
# Extract files
92-
if [ -f "$(dirname "$0")/${{ env.PACKAGE_NAME }}.tar.gz" ]; then
93-
tar -xzf "$(dirname "$0")/${{ env.PACKAGE_NAME }}.tar.gz" -C "$INSTALL_DIR"
94-
elif [ -f "$(dirname "$0")/${{ env.PACKAGE_NAME }}.zip" ]; then
95-
unzip "$(dirname "$0")/${{ env.PACKAGE_NAME }}.zip" -d "$INSTALL_DIR"
96-
else
97-
echo "Error: Neither tar.gz nor zip archive found!"
98-
exit 1
99-
fi
100-
101-
# Create symlinks in /usr/local/bin
102-
echo "Creating symlinks in /usr/local/bin..."
103-
ln -sf "$INSTALL_DIR/bin/python3" /usr/local/bin/python${{ github.event.inputs.python_version }}
104-
ln -sf "$INSTALL_DIR/bin/pip3" /usr/local/bin/pip${{ github.event.inputs.python_version }}
105-
106-
echo "Python ${{ github.event.inputs.python_version }} has been installed successfully!"
107-
echo "You can use it with: python${{ github.event.inputs.python_version }}"
108-
EOF
109-
110-
chmod +x install.sh
111-
11284
- name: Create checksum file
11385
run: |
114-
sha256sum ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}.zip install.sh > SHA256SUMS.txt
86+
sha256sum ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}.zip > SHA256SUMS.txt
11587
11688
- name: Create Release
11789
id: create_release
@@ -127,35 +99,14 @@ jobs:
12799
- Optimization Level: 2 (full optimizations with LTO)
128100
- With Pip/Setuptools/Wheel: Yes
129101
- Architecture: $(uname -m)
130-
- Build Date: 2025-04-16 14:06:18
102+
- Build Date: ${{ env.BUILD_DATE }}
131103
- Built by: anubhavkrishna1
132104
133-
**Installation Instructions:**
134-
```bash
135-
# Download the release files (choose either tar.gz or zip)
136-
wget https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/${{ env.PACKAGE_NAME }}.tar.gz
137-
# OR
138-
wget https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/${{ env.PACKAGE_NAME }}.zip
139-
140-
# Download the installation script
141-
wget https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/install.sh
142-
143-
# Verify checksums
144-
wget https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/SHA256SUMS.txt
145-
sha256sum -c SHA256SUMS.txt
146-
147-
# Install (system-wide)
148-
sudo bash install.sh
149-
150-
# Or install to custom location
151-
sudo bash install.sh /path/to/custom/location
152-
```
153105
draft: false
154106
prerelease: false
155107
files: |
156108
${{ env.PACKAGE_NAME }}.tar.gz
157109
${{ env.PACKAGE_NAME }}.zip
158-
install.sh
159110
SHA256SUMS.txt
160111
env:
161112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)