Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,17 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
# quay.io/pypa/manylinux_2_28_x86_64:2026.08.24-1
container_image: quay.io/pypa/manylinux_2_28_x86_64@sha256:4dc41da7df20400310c80d162a2fe2d2c2f3d9734d8dec20f6b9843711618deb
- arch: arm64
# quay.io/pypa/manylinux_2_28_aarch64:2026.08.24-1
container_image: quay.io/pypa/manylinux_2_28_aarch64@sha256:29a6ceb78de5b00494e6e7456a72782a4cb54238de102e7491d15fe47789b4d1
runs-on: prod-aisimulate-default-${{ matrix.arch }}-v1
timeout-minutes: 10
container:
image: ${{ vars.CI_JOB_CONTAINER_IMAGE }}
image: ${{ matrix.container_image }}
Comment thread
saturley-hall marked this conversation as resolved.
Resolved
env:
HOME: /__w/aisimulate/aisimulate
USER: runner
Expand All @@ -587,8 +593,7 @@ jobs:
python-version: "3.12"
- run: python -m pip install 'maturin>=1.12,<2'
- name: Build the application test wheel once
run: python -m maturin build --release --out ../../application-test-dist
working-directory: python/aisimulate
run: python scripts/build_manylinux_wheel.py --output-dir application-test-dist
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: application-test-wheel-${{ matrix.arch }}
Expand Down Expand Up @@ -798,10 +803,16 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
# quay.io/pypa/manylinux_2_28_x86_64:2026.08.24-1
container_image: quay.io/pypa/manylinux_2_28_x86_64@sha256:4dc41da7df20400310c80d162a2fe2d2c2f3d9734d8dec20f6b9843711618deb
- arch: arm64
# quay.io/pypa/manylinux_2_28_aarch64:2026.08.24-1
container_image: quay.io/pypa/manylinux_2_28_aarch64@sha256:29a6ceb78de5b00494e6e7456a72782a4cb54238de102e7491d15fe47789b4d1
runs-on: prod-aisimulate-default-${{ matrix.arch }}-v1
container:
image: ${{ vars.CI_JOB_CONTAINER_IMAGE }}
image: ${{ matrix.container_image }}
env:
HOME: /__w/aisimulate/aisimulate
USER: runner
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/fpe-support-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
runs-on: prod-aisimulate-default-amd64-v1
timeout-minutes: 30
container:
image: ${{ vars.CI_JOB_CONTAINER_IMAGE }}
# quay.io/pypa/manylinux_2_28_x86_64:2026.08.24-1
image: quay.io/pypa/manylinux_2_28_x86_64@sha256:4dc41da7df20400310c80d162a2fe2d2c2f3d9734d8dec20f6b9843711618deb
env:
HOME: /__w/aisimulate/aisimulate
USER: runner
Expand All @@ -52,7 +53,7 @@ jobs:
if: inputs.wheel_artifact == ''
run: |
python -m pip install 'maturin>=1.12,<2'
(cd python/aisimulate && python -m maturin build --release --out ../../fpe-wheel)
python scripts/build_manylinux_wheel.py --output-dir fpe-wheel
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
if: inputs.wheel_artifact != ''
with:
Expand Down
26 changes: 20 additions & 6 deletions python/aisimulate/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ENV MPLCONFIGDIR=/tmp/matplotlib
# One `aisimulate` wheel owns the application, compatibility namespaces,
# SDK/data payload, Replay runtime, and unified Rust extension. It is built in
# the PyPA manylinux_2_28 image so the native PyO3 `.so` links glibc 2.28 and
# maturin's auditwheel stamps the portable
# standalone auditwheel repairs and stamps the portable
# `manylinux_2_28_<arch>` tag. We add `uv` and a rustup toolchain so cargo can
# fetch crates over TLS.
#
Expand Down Expand Up @@ -70,12 +70,26 @@ RUN set -e; \
echo "Run 'git lfs install && git lfs pull' in the source tree before building." >&2; \
exit 1; \
fi
# `uv build` runs maturin's PEP517 backend, which defaults to `--compatibility
# off`; MATURIN_PEP517_ARGS overrides it to stamp the manylinux_2_28 tag (maturin
# appends it last, so it wins). `python` isn't on PATH here -> verify via UV_PYTHON.
# Match Dynamo's release-wheel boundary: Maturin emits an unaudited wheel,
# then the standalone auditwheel tool repairs and retags that exact wheel.
# Compiling in this manylinux_2_28 image ensures repair never tries to claim a
# policy older than the glibc symbols in the native extension.
RUN cd /workspace/python/aisimulate && \
MATURIN_PEP517_ARGS="--compatibility manylinux_2_28" \
uv build --wheel --out-dir /workspace/dist && \
mkdir -p /workspace/unrepaired-dist && \
MATURIN_PEP517_ARGS="--auditwheel skip" \
uv build --wheel --out-dir /workspace/unrepaired-dist && \
set -- /workspace/unrepaired-dist/aisimulate-*.whl && \
[ "$#" -eq 1 ] && [ -f "$1" ] && \
case "$(uname -m)" in \
x86_64) manylinux_policy=manylinux_2_28_x86_64 ;; \
aarch64|arm64) manylinux_policy=manylinux_2_28_aarch64 ;; \
*) echo "unsupported wheel architecture: $(uname -m)" >&2; exit 1 ;; \
esac && \
auditwheel repair \
--plat "${manylinux_policy}" \
--wheel-dir /workspace/dist \
"$1" && \
auditwheel show /workspace/dist/aisimulate-*.whl && \
"${UV_PYTHON}" tools/verify_release_wheels.py /workspace/dist

# Exercise the one-wheel boundary outside the checkout, including all
Expand Down
102 changes: 102 additions & 0 deletions scripts/build_manylinux_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Build one Linux wheel and repair it for the manylinux 2.28 policy."""

from __future__ import annotations

import argparse
import platform
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
PYTHON_PROJECT = ROOT / "python" / "aisimulate"
PLATFORM_BY_MACHINE = {
"aarch64": "manylinux_2_28_aarch64",
"arm64": "manylinux_2_28_aarch64",
"amd64": "manylinux_2_28_x86_64",
"x86_64": "manylinux_2_28_x86_64",
}


def manylinux_platform(machine: str | None = None) -> str:
"""Return the required manylinux policy for the native architecture."""
machine = (machine or platform.machine()).lower()
try:
return PLATFORM_BY_MACHINE[machine]
except KeyError as error:
supported = ", ".join(sorted(PLATFORM_BY_MACHINE))
raise SystemExit(f"unsupported wheel architecture {machine!r}; expected one of: {supported}") from error


def _run(*command: str, cwd: Path = ROOT) -> None:
subprocess.run(command, cwd=cwd, check=True)


def _single_wheel(directory: Path, description: str) -> Path:
wheels = sorted(directory.glob("aisimulate-*.whl"))
if len(wheels) != 1:
names = [path.name for path in wheels]
raise SystemExit(f"expected exactly one {description}, found {names}")
return wheels[0]


def build(output: Path) -> Path:
"""Build an unrepaired wheel, then make auditwheel produce the final wheel."""
if not sys.platform.startswith("linux"):
raise SystemExit("the manylinux wheel builder must run on Linux")
if shutil.which("auditwheel") is None:
raise SystemExit("auditwheel is required; run inside the pinned manylinux image")

policy = manylinux_platform()
output.mkdir(parents=True, exist_ok=True)
if any(output.iterdir()):
raise SystemExit(f"output directory must be empty: {output}")

with tempfile.TemporaryDirectory(prefix="aisimulate-unrepaired-wheel-") as temp:
raw_output = Path(temp)
_run(
sys.executable,
"-m",
"maturin",
"build",
"--release",
"--auditwheel",
"skip",
"--out",
str(raw_output),
cwd=PYTHON_PROJECT,
)
raw_wheel = _single_wheel(raw_output, "unrepaired AISimulate wheel")
_run(
"auditwheel",
"repair",
"--plat",
policy,
"--wheel-dir",
str(output),
str(raw_wheel),
)

repaired_wheel = _single_wheel(output, "repaired AISimulate wheel")
if policy not in repaired_wheel.name:
raise SystemExit(f"repaired wheel does not carry required tag {policy}: {repaired_wheel.name}")
_run("auditwheel", "show", str(repaired_wheel))
print(f"built {repaired_wheel}")
return repaired_wheel


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--output-dir", type=Path, default=ROOT / "dist")
args = parser.parse_args()
build(args.output_dir.resolve())


if __name__ == "__main__":
main()
77 changes: 30 additions & 47 deletions scripts/build_release_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ def _is_source_manifest(path: Path) -> bool:
def check_manifests() -> tuple[str, str]:
"""Validate the manifest set; return (wheel version, crate version)."""
pyprojects = {
path: str(_toml(path)["project"]["name"])
for path in ROOT.rglob("pyproject.toml")
if _is_source_manifest(path)
path: str(_toml(path)["project"]["name"]) for path in ROOT.rglob("pyproject.toml") if _is_source_manifest(path)
}
assert pyprojects == EXPECTED_PYTHON_PROJECTS, (
"publishable Python manifest set changed:\n"
f"expected={EXPECTED_PYTHON_PROJECTS}\nactual={pyprojects}"
f"publishable Python manifest set changed:\nexpected={EXPECTED_PYTHON_PROJECTS}\nactual={pyprojects}"
)

publishable_crates: dict[Path, str] = {}
Expand All @@ -71,32 +68,20 @@ def check_manifests() -> tuple[str, str]:
py_version = str(app["version"])
crate_version = str(crate["version"])
dev_suffix = py_version.removeprefix(VERSION)
assert py_version.startswith(VERSION) and (
dev_suffix == "" or DEV_SUFFIX_RE.fullmatch(dev_suffix)
), f"wheel version must be {VERSION} or {VERSION}.devYYYYMMDD, got {py_version}"
expected_crate_version = (
f"{VERSION}-dev.{dev_suffix[len('.dev'):]}" if dev_suffix else VERSION
assert py_version.startswith(VERSION) and (dev_suffix == "" or DEV_SUFFIX_RE.fullmatch(dev_suffix)), (
f"wheel version must be {VERSION} or {VERSION}.devYYYYMMDD, got {py_version}"
)
expected_crate_version = f"{VERSION}-dev.{dev_suffix[len('.dev') :]}" if dev_suffix else VERSION
assert crate_version == expected_crate_version, (
f"crate version {crate_version} does not match wheel version "
f"{py_version} (expected {expected_crate_version})"
f"crate version {crate_version} does not match wheel version {py_version} (expected {expected_crate_version})"
)
optional_dependencies = app.get("optional-dependencies", {})
dependencies = [
*app["dependencies"],
*(
dependency
for group in optional_dependencies.values()
for dependency in group
),
*(dependency for group in optional_dependencies.values() for dependency in group),
]
assert not any(
str(dep).lower().startswith(("aisimulate-core", "aiconfigurator"))
for dep in dependencies
)
assert not any(
str(dep).lower().startswith(("dynamo", "ai-dynamo")) for dep in dependencies
)
assert not any(str(dep).lower().startswith(("aisimulate-core", "aiconfigurator")) for dep in dependencies)
assert not any(str(dep).lower().startswith(("dynamo", "ai-dynamo")) for dep in dependencies)
assert app["scripts"] == {
"aiconfigurator": "aiconfigurator.main:main",
"aisimulate": "aisimulate.main:main",
Expand All @@ -117,16 +102,24 @@ def build(output: Path, py_version: str, crate_version: str) -> None:
if any(output.iterdir()):
raise SystemExit(f"output directory must be empty: {output}")

_run(
sys.executable,
"-m",
"maturin",
"build",
"--release",
"--out",
str(output),
cwd=ROOT / "python" / "aisimulate",
)
if sys.platform.startswith("linux"):
_run(
sys.executable,
str(ROOT / "scripts" / "build_manylinux_wheel.py"),
"--output-dir",
str(output),
)
else:
_run(
sys.executable,
"-m",
"maturin",
"build",
"--release",
"--out",
str(output),
cwd=ROOT / "python" / "aisimulate",
)

with tempfile.TemporaryDirectory(prefix="aisimulate-crate-") as temp:
target = Path(temp) / "target"
Expand All @@ -151,25 +144,15 @@ def build(output: Path, py_version: str, crate_version: str) -> None:
def verify_output(output: Path, py_version: str, crate_version: str) -> None:
names = sorted(path.name for path in output.iterdir() if path.is_file())
expected_crate = f"aisimulate-core-{crate_version}.crate"
app_wheels = [
name
for name in names
if name.startswith(f"aisimulate-{py_version}-") and name.endswith(".whl")
]
app_wheels = [name for name in names if name.startswith(f"aisimulate-{py_version}-") and name.endswith(".whl")]
assert len(names) == 2, f"expected exactly two artifacts, got {names}"
assert len(app_wheels) == 1, f"missing or duplicate aisimulate wheel: {names}"
assert expected_crate in names, f"missing {expected_crate}: {names}"
wheel_path = output / app_wheels[0]
with zipfile.ZipFile(wheel_path) as wheel:
for legal_file in LEGAL_FILES:
matches = [
name
for name in wheel.namelist()
if name.endswith(f".dist-info/licenses/{legal_file}")
]
assert len(matches) == 1, (
f"expected one packaged {legal_file}, found {matches}"
)
matches = [name for name in wheel.namelist() if name.endswith(f".dist-info/licenses/{legal_file}")]
assert len(matches) == 1, f"expected one packaged {legal_file}, found {matches}"
assert wheel.read(matches[0]) == (ROOT / legal_file).read_bytes(), (
f"packaged {legal_file} differs from the root original"
)
Expand Down
Loading
Loading