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
88 changes: 0 additions & 88 deletions .github/actions/build-pgo-wheel/action.yml

This file was deleted.

137 changes: 38 additions & 99 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ jobs:
name: pypi_files-sdist
path: crates/monty-python/dist

# Build wheels for exotic architectures (non-PGO)
# Build extension wheels and one runtime wheel for every supported platform
build:
name: build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
# only run on push to main, on tags, or if 'Full Build' label is present
Expand All @@ -483,35 +483,44 @@ jobs:
fail-fast: false
matrix:
include:
# Linux aarch64
- os: linux
target: x86_64
pgo-runtime: true
- os: linux
target: aarch64
# Linux i686
pgo-runtime: false
- os: linux
target: i686
# Linux armv7
pgo-runtime: false
- os: linux
target: armv7
# Linux ppc64le
pgo-runtime: false
- os: linux
target: ppc64le
# Linux s390x
pgo-runtime: false
- os: linux
target: s390x
# Linux x86_64 musl
pgo-runtime: false
- os: linux
target: x86_64
manylinux: musllinux_1_1
# Linux aarch64 musl
pgo-runtime: false
- os: linux
target: aarch64
manylinux: musllinux_1_1
# macOS x86_64 (Intel)
pgo-runtime: false
- os: macos
target: aarch64
pgo-runtime: true
- os: macos
target: x86_64
# Windows i686
pgo-runtime: false
- os: windows
target: x86_64
pgo-runtime: true
- os: windows
target: i686
pgo-runtime: false

runs-on: ${{ (matrix.os == 'linux' && 'ubuntu-latest') || (matrix.os == 'macos' && 'macos-latest') || (matrix.os == 'windows' && 'windows-latest') }}
steps:
Expand All @@ -523,7 +532,7 @@ jobs:
with:
python-version: '3.12'

- name: build wheels
- name: build Python wheels
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
with:
target: ${{ matrix.target }}
Expand All @@ -533,101 +542,30 @@ jobs:
docker-options: -e CI
working-directory: crates/monty-python

# the pydantic-monty-runtime wheel ships the `monty` worker binary
# (bin bindings, one py3-none wheel per platform). `-i` is required so
# maturin can find a Python to read pyproject.toml — the produced wheel
# is `py3-none-<plat>` and doesn't depend on a specific Python version.
- name: build cli wheel
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'manylinux_2_28' }}
args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14
rust-toolchain: stable
docker-options: -e CI
working-directory: crates/monty-runtime

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: pypi_files-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'manylinux' }}
name: pypi_files-python-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'manylinux' }}
path: crates/monty-python/dist

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: pypi_files-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'manylinux' }}-cli
path: crates/monty-runtime/dist

# PGO-optimized builds for main platforms
build-pgo:
name: build pgo on ${{ matrix.os }}
# only run on push to main, on tags, or if 'Full Build' label is present
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build') || (github.event_name == 'workflow_dispatch' && inputs.run_release)
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 (manylinux)
- os: linux
runs-on: ubuntu-latest
interpreter: 3.10 3.11 3.12 3.13 3.14
# Windows x86_64
- os: windows
runs-on: windows-latest
interpreter: 3.10 3.11 3.12 3.13 3.14
# macOS aarch64 (Apple Silicon)
- os: macos
runs-on: macos-latest
interpreter: 3.10 3.11 3.12 3.13 3.14

runs-on: ${{ matrix.runs-on }}

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'

# no release versioning, see https://github.com/dtolnay/rust-toolchain/issues/180
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
with:
toolchain: stable
components: llvm-tools

- name: build PGO wheel
id: pgo
uses: ./.github/actions/build-pgo-wheel
with:
interpreter: ${{ matrix.interpreter }}
rust-toolchain: stable

# the PGO-optimized cli wheel for the main platforms — reuses the
# merged profile data from the build-pgo-wheel action above (which
# exercised an instrumented monty binary via `exercise.py`).
# `-i` is required so maturin can find a Python to read pyproject.toml
# inside the manylinux docker container; the produced wheel is
# `py3-none-<plat>` and doesn't depend on a specific Python version.
- name: build cli wheel
# Maturin performs one PGO cycle for bin bindings, then packages the
# runtime for each supported Python tag.
- name: build runtime wheel
uses: PyO3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad # v1.50.1
with:
manylinux: manylinux_2_28
args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'manylinux_2_28' }}
# FIXME: should not need `-i`
# see https://github.com/PyO3/maturin/issues/3256 which causes per-version builds
args: --release ${{ matrix.pgo-runtime && '--pgo' || '' }} --out dist -i 3.10 3.11 3.12 3.13 3.14
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
maturin-version: v1.14.1
rust-toolchain: stable
rustup-components: ${{ matrix.pgo-runtime && 'llvm-tools-preview' || '' }}
docker-options: -e CI
working-directory: crates/monty-runtime
env:
RUSTFLAGS: '-Cprofile-use=${{ github.workspace }}/merged.profdata'

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: pypi_files-${{ matrix.os }}-pgo
path: ${{ steps.pgo.outputs.wheel-dir }}

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: pypi_files-${{ matrix.os }}-pgo-cli
name: pypi_files-runtime-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'manylinux' }}
path: crates/monty-runtime/dist

# Test wheels on exotic architectures via QEMU
Expand All @@ -648,7 +586,7 @@ jobs:

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: pypi_files-linux-${{ matrix.target }}-*
pattern: pypi_files-*-linux-${{ matrix.target }}-*
merge-multiple: true
path: dist

Expand Down Expand Up @@ -679,7 +617,7 @@ jobs:
# Test wheels on main OS platforms
test-builds-os:
name: test build on ${{ matrix.os }}
needs: [build, build-pgo]
needs: [build]
runs-on: ${{ matrix.runs-on }}

strategy:
Expand All @@ -704,7 +642,7 @@ jobs:

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: pypi_files-${{ matrix.os }}-*
pattern: pypi_files-*-${{ matrix.os }}-*
merge-multiple: true
path: dist

Expand Down Expand Up @@ -736,7 +674,7 @@ jobs:

# Inspect built artifacts
inspect-python-assets:
needs: [build, build-pgo, build-sdist]
needs: [build, build-sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand All @@ -745,11 +683,12 @@ jobs:
merge-multiple: true
path: dist

# FIXME: the count needs updating if the runtime can be built as a single version-agnostic wheel
- name: list files
run: |
ls -lhR dist/
ls -1 dist/ | wc -l
echo "Expected ~62 files (5 Python versions × 10 platform variants + 12 cli wheels + sdists)"
echo "Expected 122 files (5 Python versions × 12 platform variants × 2 packages + 2 sdists)"

- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ make build-wasm Build the lean wasm worker module (requires the wasm32
make test-wasm Test the wasm worker pool/transport (requires a prior build-wasm)
make build-cpython-image Build the monty-cpython docker image (locally by default)
make upload-cpython-image Build the monty-cpython docker image and push to ghcr.io/pydantic/monty-cpython
make dev-py-pgo Install the python package for development with profile-guided optimization
make dev-py-pgo Install the Python package with a PGO-optimized Monty runtime
make format-rs Format Rust code with fmt
make format-py Format Python code - WARNING be careful about this command as it may modify code and break tests silently!
make format-js Format JS code with prettier
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ upload-cpython-image: ## Build the monty-cpython docker image and push to ghcr.i
BUILDX_OUTPUT=--push

.PHONY: dev-py-pgo
dev-py-pgo: ## Install the python package for development with profile-guided optimization
$(eval PROFDATA := $(shell mktemp -d))
RUSTFLAGS='-Cprofile-generate=$(PROFDATA)' uv run maturin develop --uv -m crates/monty-python/Cargo.toml --release
uv run --package pydantic-monty --only-dev pytest crates/monty-python/tests -k "not test_parallel_exec"
$(eval LLVM_PROFDATA := $(shell rustup run stable bash -c 'echo $$RUSTUP_HOME/toolchains/$$RUSTUP_TOOLCHAIN/lib/rustlib/$$(rustc -Vv | grep host | cut -d " " -f 2)/bin/llvm-profdata'))
$(LLVM_PROFDATA) merge -o $(PROFDATA)/merged.profdata $(PROFDATA)
RUSTFLAGS='-Cprofile-use=$(PROFDATA)/merged.profdata' $(uv-run-no-sync) maturin develop --uv -m crates/monty-python/Cargo.toml --release
@rm -rf $(PROFDATA)
dev-py-pgo: ## Install the Python package with a PGO-optimized Monty interpreter
rustup component add llvm-tools --toolchain stable
rm -rf target/pgo-wheels
uvx --from 'maturin==1.14.1' maturin build -m crates/monty-runtime/Cargo.toml --release --pgo -i "$$(uv run python -c 'import sys; print(sys.executable)')" --out target/pgo-wheels
uv pip install --python "$$(uv run python -c 'import sys; print(sys.executable)')" --reinstall --no-deps target/pgo-wheels/pydantic_monty_runtime-*.whl
uv run maturin develop --uv -m crates/monty-python/Cargo.toml --release

.PHONY: format-rs
format-rs: ## Format Rust code with fmt
Expand Down
2 changes: 2 additions & 0 deletions crates/monty-datatest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ edition = { workspace = true }
authors = { workspace = true }
description = "Datatest harness for Monty — runs test cases against both Monty and CPython"
publish = false
default-run = "monty-datatest"

[dependencies]
monty = { workspace = true, features = ["test-hooks"] }
monty-pool = { workspace = true }
pyo3 = { workspace = true, features = ["auto-initialize"] }
ahash = { workspace = true }
chrono = "0.4"
Expand Down
Loading
Loading