Skip to content

Commit

Permalink
PGO build for MacOS M1 (#1063)
Browse files Browse the repository at this point in the history
Co-authored-by: David Hewitt <mail@davidhewitt.io>
  • Loading branch information
samuelcolvin and davidhewitt authored Nov 7, 2023
1 parent d80c454 commit 0c46146
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
74 changes: 51 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12-dev'
- '3.12'
- 'pypy3.7'
- 'pypy3.8'
- 'pypy3.9'
Expand Down Expand Up @@ -389,7 +389,7 @@ jobs:
interpreter: 3.11 3.12
- os: macos
target: aarch64
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10
interpreter: 3.7 3.8 3.9 pypy3.8 pypy3.9 pypy3.10
- os: ubuntu
platform: linux
target: i686
Expand Down Expand Up @@ -465,33 +465,33 @@ jobs:
path: dist

build-pgo:
name: build pgo-optimized on ${{ matrix.platform || matrix.os }} (${{ matrix.interpreter}} - ${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
name: build pgo-optimized on ${{ matrix.os }} / ${{ matrix.interpreter }}
# only run on push to main and on release
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
target: [x86_64]
manylinux: [auto]
interpreter: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev", "pypy3.7", "pypy3.8", "pypy3.9", "pypy3.10"]
os: [ubuntu-latest, windows-latest, macos-latest-xlarge]
interpreter: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
include:
- os: ubuntu
platform: linux
- os: windows
- os: windows-latest
ls: dir
- interpreter: 3.12-dev
maturin-interpreter: "3.12"

runs-on: ${{ matrix.os }}-latest
exclude:
- os: macos-latest-xlarge
interpreter: '3.7'
- os: macos-latest-xlarge
interpreter: '3.8'
- os: macos-latest-xlarge
interpreter: '3.9'

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.interpreter }}
architecture: ${{ matrix.python-architecture || 'x64' }}

- name: install rust stable
id: rust-toolchain
Expand All @@ -504,15 +504,15 @@ jobs:
# generate self-schema now, so we don't have to do so inside docker in maturin build
- run: python generate_self_schema.py

- run: rustc --version --verbose

- name: build initial wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
args: >
--release
--out pgo-wheel
--interpreter ${{ matrix.maturin-interpreter || matrix.interpreter }}
--interpreter ${{ matrix.interpreter }}
rust-toolchain: stable
docker-options: -e CI
env:
Expand All @@ -536,12 +536,10 @@ jobs:
- name: build pgo-optimized wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
args: >
--release
--out dist
--interpreter ${{ matrix.maturin-interpreter || matrix.interpreter }}
--interpreter ${{ matrix.interpreter }}
rust-toolchain: stable
docker-options: -e CI
env:
Expand All @@ -551,7 +549,7 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: pypi_files
name: pypi_files_pgo
path: dist

inspect-pypi-assets:
Expand All @@ -567,7 +565,19 @@ jobs:
name: pypi_files
path: dist

- name: list dist files
- name: list dist files before PGO builds
run: |
ls -lh dist/
ls -l dist/
echo "`ls dist | wc -l` files"
- name: get PGO dist artifacts (comes after "get dist artifacts" to so these files override the non-PGO builds)
uses: actions/download-artifact@v3
with:
name: pypi_files_pgo
path: dist

- name: list dist files with PGO builds
run: |
ls -lh dist/
ls -l dist/
Expand Down Expand Up @@ -607,6 +617,12 @@ jobs:
name: pypi_files
path: dist

- name: get PGO dist artifacts (comes after "get dist artifacts" to so these files override the non-PGO builds)
uses: actions/download-artifact@v3
with:
name: pypi_files_pgo
path: dist

- uses: uraimo/run-on-arch-action@v2.5.1
name: install & test
with:
Expand Down Expand Up @@ -659,6 +675,12 @@ jobs:
name: pypi_files
path: dist

- name: get PGO dist artifacts (comes after "get dist artifacts" to so these files override the non-PGO builds)
uses: actions/download-artifact@v3
with:
name: pypi_files_pgo
path: dist

- run: pip install typing-extensions
- run: pip install -r tests/requirements.txt
- run: pip install pydantic-core --no-index --no-deps --find-links dist --force-reinstall
Expand Down Expand Up @@ -688,6 +710,12 @@ jobs:
name: pypi_files
path: dist

- name: get PGO dist artifacts (comes after "get dist artifacts" to so these files override the non-PGO builds)
uses: actions/download-artifact@v3
with:
name: pypi_files_pgo
path: dist

- run: twine check --strict dist/*

- name: upload to pypi
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pydantic-core"
version = "2.12.0"
version = "2.13.0"
edition = "2021"
license = "MIT"
homepage = "https://github.com/pydantic/pydantic-core"
Expand Down
2 changes: 0 additions & 2 deletions src/input/input_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ impl AsLocItem for String {
}
}

/// TODO: it would be good to get JsonInput and StringMapping string variants to go through this
/// implementation
/// Required for JSON Object keys so the string can behave like an Input
impl<'a> Input<'a> for String {
fn as_error_value(&'a self) -> InputValue<'a> {
Expand Down

0 comments on commit 0c46146

Please sign in to comment.