diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cae9a192..9edef393 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,6 +56,7 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} crate-build-matrix: ${{ steps.set-matrix.outputs.crate-build-matrix }} + dep-build-matrix: ${{ steps.set-matrix.outputs.dep-build-matrix }} any_builds: ${{ steps.set-matrix.outputs.any_builds }} steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -97,6 +98,7 @@ jobs: # Extract python-build matrix echo "matrix=$(jq -c '."python-build"' matrix.json)" >> $GITHUB_OUTPUT echo "crate-build-matrix=$(jq -c '."crate-build"' matrix.json)" >> $GITHUB_OUTPUT + echo "dep-build-matrix=$(jq -c '."deps-build"' matrix.json)" >> $GITHUB_OUTPUT # Display the matrix for debugging too cat matrix.json | jq @@ -116,6 +118,7 @@ jobs: needs: - generate-matrix - crate-build + - build-deps # Permissions used for actions/attest-build-provenance permissions: id-token: write @@ -152,10 +155,17 @@ jobs: run: | uv run build.py --help + - name: Download build dependencies + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: build-deps-${{ matrix.target_triple }}-${{ matrix.build_options}} + path: build + - name: Build if: ${{ ! matrix.dry-run }} shell: cmd run: | + DIR IF "%MATRIX_VS_VERSION%"=="2026" ( call "C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Auxiliary\Build\%MATRIX_VCVARS%" ) ELSE ( @@ -185,3 +195,56 @@ jobs: run: | $Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative .\pythonbuild.exe validate-distribution --run $Dists + + build-deps: + timeout-minutes: 90 + needs: + - generate-matrix + # Permissions used for actions/attest-build-provenance + runs-on: ${{ matrix.runner }} + strategy: + matrix: ${{ fromJson(needs.generate-matrix.outputs.dep-build-matrix) }} + fail-fast: false + name: build-deps / ${{ matrix.target_triple }} / ${{ matrix.build_options }} + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install Cygwin Environment + uses: cygwin/cygwin-install-action@f2009323764960f80959895c7bc3bb30210afe4d # v6 + with: + packages: autoconf automake libtool + + - name: Set up uv + uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 + with: + enable-cache: false + + # We need to do this before we activate the VC++ environment or else binary packages + # don't get compiled properly. + - name: Bootstrap Python environment + run: | + uv run build.py --help + + - name: Build + if: ${{ ! matrix.dry-run }} + shell: cmd + run: | + IF "%MATRIX_VS_VERSION%"=="2026" ( + call "C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Auxiliary\Build\%MATRIX_VCVARS%" + ) ELSE ( + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\%MATRIX_VCVARS%" + ) + uv run build.py --only-deps --sh c:\cygwin\bin\sh.exe --options %MATRIX_BUILD_OPTIONS% --vs %MATRIX_VS_VERSION% + env: + MATRIX_VCVARS: ${{ matrix.vcvars }} + MATRIX_BUILD_OPTIONS: ${{ matrix.build_options }} + MATRIX_VS_VERSION: ${{ matrix.vs_version }} + + - name: Upload Build Dependencies + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: build-deps-${{ matrix.target_triple }}-${{ matrix.build_options }} + path: build/*.tar \ No newline at end of file diff --git a/ci-matrix.py b/ci-matrix.py index c88f09b2..abbc8476 100644 --- a/ci-matrix.py +++ b/ci-matrix.py @@ -127,6 +127,30 @@ def generate_docker_matrix_entries( return matrix_entries +def generate_deps_build_matrix_entries( + python_entries: list[dict[str, str]], + platform_filter: str | None = None, +) -> list[dict[str, str]]: + """Generate matrix entries for deps builds based on python build matrix.""" + include_keys = { + "arch", + "target_triple", + "platform", + "runner", + "build_options", + "vcvars", + "vs_version", + } + dep_build_pairs = set() + for entry in python_entries: + platform = entry["platform"] + if platform_filter and platform != platform_filter: + continue + pairs = tuple((k, v) for k, v in entry.items() if k in include_keys) + dep_build_pairs.add(pairs) + return [dict(pairs) for pairs in dep_build_pairs] + + def generate_crate_build_matrix_entries( python_entries: list[dict[str, str]], runners: dict[str, Any], @@ -355,7 +379,7 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument( "--matrix-type", - choices=["python-build", "docker-build", "crate-build", "all"], + choices=["python-build", "docker-build", "crate-build", "deps-build", "all"], default="all", help="Which matrix types to generate (default: all)", ) @@ -443,6 +467,14 @@ def main() -> None: ) result["crate-build"] = {"include": crate_entries} + # Generate deps-build matrix if requested + if args.matrix_type in ["deps-build", "all"]: + deps_entries = generate_deps_build_matrix_entries( + python_entries, + args.platform, + ) + result["deps-build"] = {"include": deps_entries} + print(json.dumps(result)) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 3b27e679..8e58882e 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -1910,6 +1910,11 @@ def main() -> None: default="10.0.26100.0", help="Windows SDK version to build with", ) + parser.add_argument( + "--only-deps", + action='store_true', + help="Build only dependencies, not CPython", + ) args = parser.parse_args() build_options = args.options @@ -1964,6 +1969,10 @@ def main() -> None: libffi_archive, ) + # Stop if only building dependencies + if args.only_deps: + return + LOG_PREFIX[0] = "cpython" tar_path = build_cpython( args.python,