Skip to content
Open
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
63 changes: 63 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
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 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We generally prefer verbose names like "dependency" over short ones like "dep"

any_builds: ${{ steps.set-matrix.outputs.any_builds }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand Down Expand Up @@ -97,6 +98,7 @@
# 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
Expand All @@ -116,6 +118,7 @@
needs:
- generate-matrix
- crate-build
- build-deps
# Permissions used for actions/attest-build-provenance
permissions:
id-token: write
Expand Down Expand Up @@ -151,11 +154,18 @@
- name: Bootstrap Python environment
run: |
uv run build.py --help

Check warning

Code scanning / zizmor

usage of GitHub Actions misfeatures Warning

usage of GitHub Actions misfeatures
- 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 (
Expand Down Expand Up @@ -185,3 +195,56 @@
run: |
$Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative
.\pythonbuild.exe validate-distribution --run $Dists

build-deps:
timeout-minutes: 90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

90 minutes?

needs:
- generate-matrix
# Permissions used for actions/attest-build-provenance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this comment referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left over copy and paste from the build job.

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

Check warning

Code scanning / zizmor

detects commit SHAs that don't match their version comment tags Warning

detects commit SHAs that don't match their version comment tags
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
34 changes: 33 additions & 1 deletion ci-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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)",
)
Expand Down Expand Up @@ -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))


Expand Down
9 changes: 9 additions & 0 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading