Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
267 changes: 267 additions & 0 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
name: Build Python for Multiple Platforms

on:
push:
branches:
- 'python-3.*'
- 'main'
pull_request:
branches:
- 'python-3.*'
- 'main'
workflow_dispatch:

env:
PYTHON_VERSION: 3.14.0
PYTHON_VERSION_SHORT: 3.14
PYTHON_DIST_RELEASE: 20251007

jobs:
# ======================================
# Build Python for Android
# ======================================
build-android:
name: Build Python for Android
runs-on: ubuntu-latest
permissions:
contents: write # Required for uploading to releases
env:
NDK_VERSION: r27

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Verify Python version
run: python --version

- name: Build all Python ABIs
run: |
cd android
./build-all.sh ${{ env.PYTHON_VERSION }}

- name: Package support package for mobile-forge
run: |
cd android
mkdir -p dist
tar -czf dist/python-android-mobile-forge-${{ env.PYTHON_VERSION_SHORT }}.tar.gz install support

- name: Package individual ABIs for Flutter
run: |
cd android
./package-for-dart.sh install ${{ env.PYTHON_VERSION }} arm64-v8a
./package-for-dart.sh install ${{ env.PYTHON_VERSION }} x86_64

- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: python-android
path: android/dist/python-android-*.tar.gz
if-no-files-found: error

- name: Deploy to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: android/dist/python-android-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ======================================
# Build Python for iOS and macOS
# ======================================
build-darwin:
name: Build Python for iOS and macOS
runs-on: macos-latest
permissions:
contents: write # Required for uploading to releases

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Verify Python version
run: python --version

- name: Clone Python-Apple-support
run: |
cd darwin
git clone --branch=${{ env.PYTHON_VERSION_SHORT }} https://github.com/beeware/Python-Apple-support.git
mkdir -p dist

- name: Build Python for iOS
run: |
cd darwin/Python-Apple-support
make iOS

- name: Package iOS for mobile-forge
run: |
cd darwin
tar -czf dist/python-ios-mobile-forge-${{ env.PYTHON_VERSION_SHORT }}.tar.gz \
-C Python-Apple-support install support

- name: Build Python for macOS
run: |
cd darwin/Python-Apple-support
make macOS

- name: Package for Dart - iOS
run: |
cd darwin
./package-ios-for-dart.sh Python-Apple-support ${{ env.PYTHON_VERSION_SHORT }}

- name: Package for Dart - macOS
run: |
cd darwin
./package-macos-for-dart.sh Python-Apple-support ${{ env.PYTHON_VERSION_SHORT }}

- name: Upload Darwin artifacts
uses: actions/upload-artifact@v4
with:
name: python-darwin
path: darwin/dist/python-*.tar.gz
if-no-files-found: error

- name: Deploy to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: darwin/dist/python-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ======================================
# Build Python for Linux
# ======================================
build-linux:
name: Build Python for Linux
runs-on: ubuntu-latest
permissions:
contents: write # Required for uploading to releases

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Verify Python version
run: python --version

- name: Install rsync
run: sudo apt-get update && sudo apt-get install -y rsync

- name: Build Python for Linux x86_64
run: |
cd linux
./package-for-linux.sh x86_64 "_v2"
env:
PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }}
PYTHON_DIST_RELEASE: ${{ env.PYTHON_DIST_RELEASE }}

- name: Build Python for Linux aarch64
run: |
cd linux
./package-for-linux.sh aarch64 ""
env:
PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }}
PYTHON_DIST_RELEASE: ${{ env.PYTHON_DIST_RELEASE }}

- name: List built archives
run: |
cd linux
ls -lh python-linux-dart-*.tar.gz

- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: python-linux
path: linux/python-linux-dart-*.tar.gz
if-no-files-found: error

- name: Deploy to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: linux/python-linux-dart-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ======================================
# Build Python for Windows
# ======================================
build-windows:
name: Build Python for Windows
runs-on: windows-latest
permissions:
contents: write # Required for uploading to releases

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Verify Python version
run: python --version

- name: Download Python installer
run: |
cd windows
INSTALLER_URL="https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}"
curl -OL "${INSTALLER_URL}/python-${{ env.PYTHON_VERSION }}-amd64.exe"
shell: bash

- name: Install Python
run: |
cd windows
Start-Process -Wait -FilePath "python-${{ env.PYTHON_VERSION }}-amd64.exe" `
-ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1", `
"Include_test=0", "TargetDir=C:\hostedtoolcache\windows\Python\3.14.0\x64"
shell: powershell

- name: Verify installation and compile bytecode
run: |
dir C:\hostedtoolcache\windows\Python\3.14.0\x64
C:\hostedtoolcache\windows\Python\3.14.0\x64\python.exe --version
C:\hostedtoolcache\windows\Python\3.14.0\x64\python.exe -m compileall -b C:\hostedtoolcache\windows\Python\3.14.0\x64\Lib
shell: cmd

- name: Create archive
run: |
cd windows
7z a -xr@exclude.txt python-windows-for-dart-${{ env.PYTHON_VERSION_SHORT }}.zip C:\hostedtoolcache\windows\Python\3.14.0\x64*
shell: cmd

- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: python-windows
path: windows/python-windows-for-dart-*.zip
if-no-files-found: error

- name: Deploy to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: windows/python-windows-for-dart-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Binaries and executables
actionlint

# Build artifacts
*.tar.gz
*.zip
dist/
build/
install/
support/

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
# python-build
Building Python for Android and iOS

Building Python for Android, iOS, macOS, Linux, and Windows

## Overview

This repository contains build scripts and GitHub Actions workflows for building Python 3.14 for multiple platforms:
- **Android**: All ABIs (arm64-v8a, armeabi-v7a, x86_64, x86)
- **Darwin**: iOS and macOS
- **Linux**: x86_64 and aarch64
- **Windows**: amd64

## Build Status

Builds are automated using GitHub Actions. The workflow is triggered on:
- Pushes to branches matching `python-3.*` or `main`
- Pull requests to branches matching `python-3.*` or `main`
- Manual workflow dispatch

## Build Artifacts

Build artifacts are automatically uploaded for each platform and can be downloaded from:
- GitHub Actions workflow runs (for development builds)
- GitHub Releases (for tagged releases)

### Release Process

To create a release:
1. Tag a commit with the version format: `v3.14` (matching `PYTHON_VERSION_SHORT`)
2. Push the tag to GitHub
3. GitHub Actions will automatically build all platforms and create a release with artifacts

## Platform-Specific Details

### Android
- Uses Android NDK r27
- Builds all standard ABIs
- Creates packages for mobile-forge and Flutter/Dart

### Darwin (iOS/macOS)
- Uses BeeWare's Python-Apple-support
- Builds both iOS and macOS frameworks
- Packages for Flutter/Dart integration

### Linux
- Uses python-build-standalone from Astral
- Builds for x86_64 and aarch64 architectures
- Creates stripped install-only packages

### Windows
- Downloads official Python installer
- Creates custom distribution for Flutter/Dart
- Compiles Python bytecode for distribution

## Migration from AppVeyor

This repository previously used AppVeyor for CI/CD. The migration to GitHub Actions provides:
- Better integration with GitHub
- Faster build times
- More flexible workflow configuration
- Native support for all platforms

13 changes: 7 additions & 6 deletions android/abi-to-host.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
case ${abi:?} in
armeabi-v7a)
HOST=arm-linux-androideabi
;;
# armeabi-v7a)
# # HOST=arm-linux-androideabi
# HOST=aarch64-linux-android
# ;;
arm64-v8a)
HOST=aarch64-linux-android
;;
x86)
HOST=i686-linux-android
;;
# x86)
# HOST=i686-linux-android
# ;;
x86_64)
HOST=x86_64-linux-android
;;
Expand Down
4 changes: 3 additions & 1 deletion android/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
set -eu

python_version=${1:?}
abis="arm64-v8a armeabi-v7a x86_64 x86"
abis="arm64-v8a x86_64"
# abis="arm64-v8a armeabi-v7a x86_64 x86"


for abi in $abis; do
./build.sh $python_version $abi
Expand Down
Loading
Loading