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
70 changes: 54 additions & 16 deletions .github/workflows/_build-cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ on:
required: true
type: string
source:
description: Source provider (checkout or pypi-sdist).
description: Source provider (checkout, pypi-sdist, or artifact-sdist).
required: false
default: checkout
type: string
source-artifact:
description: Artifact containing the sdist when source is artifact-sdist.
required: false
default: ''
type: string
repository:
description: Upstream owner/repository to check out when source is checkout.
required: false
Expand Down Expand Up @@ -272,13 +277,17 @@ jobs:
- name: Validate source configuration
env:
SOURCE: ${{ inputs.source }}
SOURCE_ARTIFACT: ${{ inputs['source-artifact'] }}
REPOSITORY: ${{ inputs.repository }}
run: |
case "$SOURCE" in
checkout)
test -n "$REPOSITORY"
;;
pypi-sdist) ;;
artifact-sdist)
test -n "$SOURCE_ARTIFACT"
;;
*)
echo "unsupported source: $SOURCE" >&2
exit 1
Expand All @@ -298,29 +307,24 @@ jobs:
sparse-checkout: ${{ inputs['checkout-sparse-checkout'] }}
persist-credentials: false

- name: Download and extract PyPI sdist
- name: Download PyPI sdist
if: inputs.source == 'pypi-sdist'
env:
PACKAGE: ${{ inputs.package }}
VERSION: ${{ inputs.version }}
DESTINATION: ${{ inputs.package }}
ARCHIVE_DIRECTORY: ${{ runner.temp }}/source-sdist
run: |
python3 - <<'PY'
import hashlib
import json
import os
import shutil
import stat
import tarfile
import tempfile
import urllib.parse
import urllib.request
import zipfile
from pathlib import Path, PurePosixPath
from pathlib import Path

distribution = os.environ["PACKAGE"]
version = os.environ["VERSION"]
destination = Path(os.environ["GITHUB_WORKSPACE"], os.environ["DESTINATION"])
archive_directory = Path(os.environ["ARCHIVE_DIRECTORY"])
api = "https://pypi.org/pypi/{}/{}/json".format(
urllib.parse.quote(distribution, safe=""),
urllib.parse.quote(version, safe=""),
Expand All @@ -345,7 +349,8 @@ jobs:
if filename != sdist["filename"]:
raise SystemExit(f"unsafe PyPI sdist filename: {sdist['filename']}")

archive = Path(os.environ["RUNNER_TEMP"], filename)
archive_directory.mkdir()
archive = archive_directory / filename
digest = hashlib.sha256()
request = urllib.request.Request(
sdist["url"],
Expand All @@ -359,7 +364,39 @@ jobs:
if digest.hexdigest() != expected:
raise SystemExit(f"SHA-256 mismatch for {filename}")

staging = Path(tempfile.mkdtemp(prefix="pypi-sdist-", dir=os.environ["RUNNER_TEMP"]))
print(f"Downloaded {filename} with SHA-256 {expected}")
PY

- name: Download sdist artifact
if: inputs.source == 'artifact-sdist'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs['source-artifact'] }}
path: ${{ runner.temp }}/source-sdist

- name: Extract sdist
if: inputs.source == 'pypi-sdist' || inputs.source == 'artifact-sdist'
env:
ARCHIVE_DIRECTORY: ${{ runner.temp }}/source-sdist
DESTINATION: ${{ inputs.package }}
run: |
python3 - <<'PY'
import os
import shutil
import stat
import tarfile
import tempfile
import zipfile
from pathlib import Path, PurePosixPath

archive_directory = Path(os.environ["ARCHIVE_DIRECTORY"])
archives = [path for path in archive_directory.rglob("*") if path.is_file()]
if len(archives) != 1:
raise SystemExit(
f"expected exactly one sdist file in {archive_directory}, found {len(archives)}"
)
archive = archives[0]
staging = Path(tempfile.mkdtemp(prefix="source-sdist-", dir=os.environ["RUNNER_TEMP"]))
if tarfile.is_tarfile(archive):
with tarfile.open(archive) as source:
source.extractall(staging, filter="data")
Expand All @@ -369,18 +406,19 @@ jobs:
path = PurePosixPath(member.filename)
mode = member.external_attr >> 16
if path.is_absolute() or ".." in path.parts or stat.S_ISLNK(mode):
raise SystemExit(f"unsafe path in {filename}: {member.filename}")
raise SystemExit(f"unsafe path in {archive.name}: {member.filename}")
source.extractall(staging)
else:
raise SystemExit(f"unsupported PyPI sdist archive: {filename}")
raise SystemExit(f"unsupported sdist archive: {archive.name}")

roots = [path for path in staging.iterdir() if path.name != "__MACOSX"]
if len(roots) != 1 or not roots[0].is_dir():
raise SystemExit(f"expected one source directory in {filename}")
raise SystemExit(f"expected one source directory in {archive.name}")
destination = Path(os.environ["GITHUB_WORKSPACE"], os.environ["DESTINATION"])
if destination.exists():
raise SystemExit(f"source destination already exists: {destination}")
shutil.move(roots[0], destination)
print(f"Downloaded {filename} with SHA-256 {expected}")
print(f"Extracted {archive.name} to {destination}")
PY

- name: Checkout patches
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build-alienplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ env:
# bump needs this updated by hand the same way (gotcha 103's shape).
ALIENPLATFORM_REF: b33b2c81540e1faeee91ef682f3e022039420bac
# Matches rust-toolchain.toml at that commit.
RUST_TOOLCHAIN: "nightly-2026-10-03"

jobs:
setup:
Expand Down Expand Up @@ -81,7 +80,7 @@ jobs:
# there, so no extra workspace checkout step is needed.
cibw-before-all-linux: >
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
sh -s -- -y --profile minimal --default-toolchain ${{ env.RUST_TOOLCHAIN }}
sh -s -- -y --profile minimal --default-toolchain nightly-2026-10-03
cibw-environment-linux: "PATH=\"$PATH:$HOME/.cargo/bin\" RUSTUP_TOOLCHAIN=nightly-2026-10-03"
# Base `import alienplatform` only loads the compiled extension:
# grpcio/protobuf are the optional [worker] extra, imported lazily
Expand Down
Loading