diff --git a/.appveyor.yml b/.appveyor.yml.archived similarity index 100% rename from .appveyor.yml rename to .appveyor.yml.archived diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml new file mode 100644 index 0000000..0d48cd2 --- /dev/null +++ b/.github/workflows/build-python.yml @@ -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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd414ca --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index ec7f0c6..6bb833c 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/android/abi-to-host.sh b/android/abi-to-host.sh index 6e717aa..27c52ed 100644 --- a/android/abi-to-host.sh +++ b/android/abi-to-host.sh @@ -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 ;; diff --git a/android/build-all.sh b/android/build-all.sh index 3297b77..9838544 100755 --- a/android/build-all.sh +++ b/android/build-all.sh @@ -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 diff --git a/linux/package-for-linux.sh b/linux/package-for-linux.sh index 74f6c34..8228512 100755 --- a/linux/package-for-linux.sh +++ b/linux/package-for-linux.sh @@ -7,7 +7,7 @@ mkdir -p $PYTHON_ARCH/build tar zxvf $DIST_FILE -C $PYTHON_ARCH/build # compile lib -python -m compileall -b $PYTHON_ARCH/build/python/lib/python3.12 +python -m compileall -b $PYTHON_ARCH/build/python/lib/python3.14 # copy build to dist mkdir -p $PYTHON_ARCH/dist diff --git a/windows/unattend.xml b/windows/unattend.xml index 286ae72..667fd5b 100644 --- a/windows/unattend.xml +++ b/windows/unattend.xml @@ -1,6 +1,6 @@