|
| 1 | +name: Build Python for Multiple Platforms |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'python-3.*' |
| 7 | + - 'main' |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - 'python-3.*' |
| 11 | + - 'main' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +env: |
| 15 | + PYTHON_VERSION: 3.14.0 |
| 16 | + PYTHON_VERSION_SHORT: 3.14 |
| 17 | + PYTHON_DIST_RELEASE: 20251007 |
| 18 | + |
| 19 | +jobs: |
| 20 | + # ====================================== |
| 21 | + # Build Python for Android |
| 22 | + # ====================================== |
| 23 | + build-android: |
| 24 | + name: Build Python for Android |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + contents: write # Required for uploading to releases |
| 28 | + env: |
| 29 | + NDK_VERSION: r27 |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: '3.14' |
| 39 | + |
| 40 | + - name: Verify Python version |
| 41 | + run: python --version |
| 42 | + |
| 43 | + - name: Build all Python ABIs |
| 44 | + run: | |
| 45 | + cd android |
| 46 | + ./build-all.sh ${{ env.PYTHON_VERSION }} |
| 47 | +
|
| 48 | + - name: Package support package for mobile-forge |
| 49 | + run: | |
| 50 | + cd android |
| 51 | + mkdir -p dist |
| 52 | + tar -czf dist/python-android-mobile-forge-${{ env.PYTHON_VERSION_SHORT }}.tar.gz install support |
| 53 | +
|
| 54 | + - name: Package individual ABIs for Flutter |
| 55 | + run: | |
| 56 | + cd android |
| 57 | + ./package-for-dart.sh install ${{ env.PYTHON_VERSION }} arm64-v8a |
| 58 | + ./package-for-dart.sh install ${{ env.PYTHON_VERSION }} x86_64 |
| 59 | +
|
| 60 | + - name: Upload Android artifacts |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: python-android |
| 64 | + path: android/dist/python-android-*.tar.gz |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + - name: Deploy to GitHub Release |
| 68 | + if: startsWith(github.ref, 'refs/tags/v') |
| 69 | + uses: softprops/action-gh-release@v2 |
| 70 | + with: |
| 71 | + files: android/dist/python-android-*.tar.gz |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + # ====================================== |
| 76 | + # Build Python for iOS and macOS |
| 77 | + # ====================================== |
| 78 | + build-darwin: |
| 79 | + name: Build Python for iOS and macOS |
| 80 | + runs-on: macos-latest |
| 81 | + permissions: |
| 82 | + contents: write # Required for uploading to releases |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Checkout code |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Set up Python |
| 89 | + uses: actions/setup-python@v5 |
| 90 | + with: |
| 91 | + python-version: '3.14' |
| 92 | + |
| 93 | + - name: Verify Python version |
| 94 | + run: python --version |
| 95 | + |
| 96 | + - name: Clone Python-Apple-support |
| 97 | + run: | |
| 98 | + cd darwin |
| 99 | + git clone --branch=${{ env.PYTHON_VERSION_SHORT }} https://github.com/beeware/Python-Apple-support.git |
| 100 | + mkdir -p dist |
| 101 | +
|
| 102 | + - name: Build Python for iOS |
| 103 | + run: | |
| 104 | + cd darwin/Python-Apple-support |
| 105 | + make iOS |
| 106 | +
|
| 107 | + - name: Package iOS for mobile-forge |
| 108 | + run: | |
| 109 | + cd darwin |
| 110 | + tar -czf dist/python-ios-mobile-forge-${{ env.PYTHON_VERSION_SHORT }}.tar.gz \ |
| 111 | + -C Python-Apple-support install support |
| 112 | +
|
| 113 | + - name: Build Python for macOS |
| 114 | + run: | |
| 115 | + cd darwin/Python-Apple-support |
| 116 | + make macOS |
| 117 | +
|
| 118 | + - name: Package for Dart - iOS |
| 119 | + run: | |
| 120 | + cd darwin |
| 121 | + ./package-ios-for-dart.sh Python-Apple-support ${{ env.PYTHON_VERSION_SHORT }} |
| 122 | +
|
| 123 | + - name: Package for Dart - macOS |
| 124 | + run: | |
| 125 | + cd darwin |
| 126 | + ./package-macos-for-dart.sh Python-Apple-support ${{ env.PYTHON_VERSION_SHORT }} |
| 127 | +
|
| 128 | + - name: Upload Darwin artifacts |
| 129 | + uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + name: python-darwin |
| 132 | + path: darwin/dist/python-*.tar.gz |
| 133 | + if-no-files-found: error |
| 134 | + |
| 135 | + - name: Deploy to GitHub Release |
| 136 | + if: startsWith(github.ref, 'refs/tags/v') |
| 137 | + uses: softprops/action-gh-release@v2 |
| 138 | + with: |
| 139 | + files: darwin/dist/python-*.tar.gz |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + |
| 143 | + # ====================================== |
| 144 | + # Build Python for Linux |
| 145 | + # ====================================== |
| 146 | + build-linux: |
| 147 | + name: Build Python for Linux |
| 148 | + runs-on: ubuntu-latest |
| 149 | + permissions: |
| 150 | + contents: write # Required for uploading to releases |
| 151 | + |
| 152 | + steps: |
| 153 | + - name: Checkout code |
| 154 | + uses: actions/checkout@v4 |
| 155 | + |
| 156 | + - name: Set up Python |
| 157 | + uses: actions/setup-python@v5 |
| 158 | + with: |
| 159 | + python-version: '3.14' |
| 160 | + |
| 161 | + - name: Verify Python version |
| 162 | + run: python --version |
| 163 | + |
| 164 | + - name: Install rsync |
| 165 | + run: sudo apt-get update && sudo apt-get install -y rsync |
| 166 | + |
| 167 | + - name: Build Python for Linux x86_64 |
| 168 | + run: | |
| 169 | + cd linux |
| 170 | + ./package-for-linux.sh x86_64 "_v2" |
| 171 | + env: |
| 172 | + PYTHON_VERSION: ${{ env.PYTHON_VERSION }} |
| 173 | + PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }} |
| 174 | + PYTHON_DIST_RELEASE: ${{ env.PYTHON_DIST_RELEASE }} |
| 175 | + |
| 176 | + - name: Build Python for Linux aarch64 |
| 177 | + run: | |
| 178 | + cd linux |
| 179 | + ./package-for-linux.sh aarch64 "" |
| 180 | + env: |
| 181 | + PYTHON_VERSION: ${{ env.PYTHON_VERSION }} |
| 182 | + PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }} |
| 183 | + PYTHON_DIST_RELEASE: ${{ env.PYTHON_DIST_RELEASE }} |
| 184 | + |
| 185 | + - name: List built archives |
| 186 | + run: | |
| 187 | + cd linux |
| 188 | + ls -lh python-linux-dart-*.tar.gz |
| 189 | +
|
| 190 | + - name: Upload Linux artifacts |
| 191 | + uses: actions/upload-artifact@v4 |
| 192 | + with: |
| 193 | + name: python-linux |
| 194 | + path: linux/python-linux-dart-*.tar.gz |
| 195 | + if-no-files-found: error |
| 196 | + |
| 197 | + - name: Deploy to GitHub Release |
| 198 | + if: startsWith(github.ref, 'refs/tags/v') |
| 199 | + uses: softprops/action-gh-release@v2 |
| 200 | + with: |
| 201 | + files: linux/python-linux-dart-*.tar.gz |
| 202 | + env: |
| 203 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 204 | + |
| 205 | + # ====================================== |
| 206 | + # Build Python for Windows |
| 207 | + # ====================================== |
| 208 | + build-windows: |
| 209 | + name: Build Python for Windows |
| 210 | + runs-on: windows-latest |
| 211 | + permissions: |
| 212 | + contents: write # Required for uploading to releases |
| 213 | + |
| 214 | + steps: |
| 215 | + - name: Checkout code |
| 216 | + uses: actions/checkout@v4 |
| 217 | + |
| 218 | + - name: Set up Python |
| 219 | + uses: actions/setup-python@v5 |
| 220 | + with: |
| 221 | + python-version: '3.14' |
| 222 | + |
| 223 | + - name: Verify Python version |
| 224 | + run: python --version |
| 225 | + |
| 226 | + - name: Download Python installer |
| 227 | + run: | |
| 228 | + cd windows |
| 229 | + INSTALLER_URL="https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}" |
| 230 | + curl -OL "${INSTALLER_URL}/python-${{ env.PYTHON_VERSION }}-amd64.exe" |
| 231 | + shell: bash |
| 232 | + |
| 233 | + - name: Install Python |
| 234 | + run: | |
| 235 | + cd windows |
| 236 | + Start-Process -Wait -FilePath "python-${{ env.PYTHON_VERSION }}-amd64.exe" ` |
| 237 | + -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1", ` |
| 238 | + "Include_test=0", "TargetDir=C:\hostedtoolcache\windows\Python\3.14.0\x64" |
| 239 | + shell: powershell |
| 240 | + |
| 241 | + - name: Verify installation and compile bytecode |
| 242 | + run: | |
| 243 | + dir C:\hostedtoolcache\windows\Python\3.14.0\x64 |
| 244 | + C:\hostedtoolcache\windows\Python\3.14.0\x64\python.exe --version |
| 245 | + C:\hostedtoolcache\windows\Python\3.14.0\x64\python.exe -m compileall -b C:\hostedtoolcache\windows\Python\3.14.0\x64\Lib |
| 246 | + shell: cmd |
| 247 | + |
| 248 | + - name: Create archive |
| 249 | + run: | |
| 250 | + cd windows |
| 251 | + 7z a -xr@exclude.txt python-windows-for-dart-${{ env.PYTHON_VERSION_SHORT }}.zip C:\hostedtoolcache\windows\Python\3.14.0\x64* |
| 252 | + shell: cmd |
| 253 | + |
| 254 | + - name: Upload Windows artifacts |
| 255 | + uses: actions/upload-artifact@v4 |
| 256 | + with: |
| 257 | + name: python-windows |
| 258 | + path: windows/python-windows-for-dart-*.zip |
| 259 | + if-no-files-found: error |
| 260 | + |
| 261 | + - name: Deploy to GitHub Release |
| 262 | + if: startsWith(github.ref, 'refs/tags/v') |
| 263 | + uses: softprops/action-gh-release@v2 |
| 264 | + with: |
| 265 | + files: windows/python-windows-for-dart-*.zip |
| 266 | + env: |
| 267 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments