@@ -288,10 +288,25 @@ jobs:
288
288
jobs : ${{ toJSON(needs) }}
289
289
allowed-failures : coverage
290
290
291
+ build-sdist :
292
+ name : build sdist
293
+ runs-on : ubuntu-latest
294
+ steps :
295
+ - uses : actions/checkout@v3
296
+ - uses : PyO3/maturin-action@v1
297
+ with :
298
+ command : sdist
299
+ args : --out dist
300
+ rust-toolchain : stable
301
+ - uses : actions/upload-artifact@v3
302
+ with :
303
+ name : pypi_files
304
+ path : dist
305
+
291
306
build :
292
307
name : build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
293
308
# only run on push to main and on release
294
- if : " success() && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')) "
309
+ if : startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
295
310
strategy :
296
311
fail-fast : false
297
312
matrix :
@@ -346,6 +361,11 @@ jobs:
346
361
container : messense/manylinux_2_24-cross:s390x
347
362
interpreter : 3.7 3.8 3.9 3.10 3.11
348
363
exclude :
364
+ # Optimized PGO builds for manylinux follow a different matrix, maybe in future
365
+ # maturin-action can support this automatically
366
+ - os : ubuntu
367
+ target : x86_64
368
+ manylinux : auto
349
369
# Windows on arm64 only supports Python 3.11+
350
370
- os : windows
351
371
target : aarch64
@@ -360,19 +380,11 @@ jobs:
360
380
python-version : ' 3.11'
361
381
architecture : ${{ matrix.python-architecture || 'x64' }}
362
382
363
- - run : pip install -U twine 'black>=22.3.0,<23' typing_extensions
383
+ - run : pip install -U 'black>=22.3.0,<23' typing_extensions
364
384
365
385
# generate self-schema now, so we don't have to do so inside docker in maturin build
366
386
- run : python generate_self_schema.py
367
387
368
- - name : build sdist
369
- if : ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux == 'auto' }}
370
- uses : PyO3/maturin-action@v1
371
- with :
372
- command : sdist
373
- args : --out dist
374
- rust-toolchain : stable
375
-
376
388
- name : build wheels
377
389
uses : PyO3/maturin-action@v1
378
390
with :
@@ -385,15 +397,87 @@ jobs:
385
397
386
398
- run : ${{ matrix.ls || 'ls -lh' }} dist/
387
399
388
- - run : twine check --strict dist/*
400
+ - uses : actions/upload-artifact@v3
401
+ with :
402
+ name : pypi_files
403
+ path : dist
404
+
405
+ build-pgo :
406
+ name : build pgo-optimized on ${{ matrix.platform || matrix.os }} (${{ matrix.interpreter}} - ${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
407
+ # only run on push to main and on release
408
+ if : startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
409
+ strategy :
410
+ fail-fast : false
411
+ matrix :
412
+ os : [ubuntu]
413
+ platform : [linux]
414
+ target : [x86_64]
415
+ manylinux : [auto]
416
+ interpreter : ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
417
+
418
+ runs-on : ${{ matrix.os }}-latest
419
+ steps :
420
+ - uses : actions/checkout@v3
421
+
422
+ - name : set up python
423
+ uses : actions/setup-python@v4
424
+ with :
425
+ python-version : ${{ matrix.interpreter }}
426
+ architecture : ${{ matrix.python-architecture || 'x64' }}
427
+
428
+ - name : install rust stable
429
+ id : rust-toolchain
430
+ uses : dtolnay/rust-toolchain@stable
431
+ with :
432
+ components : llvm-tools
433
+
434
+ - run : pip install -U 'black>=22.3.0,<23' typing_extensions
435
+
436
+ # generate self-schema now, so we don't have to do so inside docker in maturin build
437
+ - run : python generate_self_schema.py
438
+
439
+ - name : build initial wheel
440
+ uses : PyO3/maturin-action@v1
441
+ with :
442
+ target : ${{ matrix.target }}
443
+ manylinux : ${{ matrix.manylinux || 'auto' }}
444
+ args : >
445
+ --release
446
+ --out pgo-wheel
447
+ --interpreter ${{ matrix.interpreter }}
448
+ -- -Cprofile-generate=${{ github.workspace }}/profdata
449
+ rust-toolchain : stable
450
+
451
+ - name : generate pgo data
452
+ run : |
453
+ pip install -U pip
454
+ pip install -r tests/requirements.txt
455
+ pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
456
+ cd tests # change directory to avoid importing local pydantic_core source
457
+ pytest tests/benchmarks
458
+ rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
459
+
460
+ - name : build pgo-optimized wheel
461
+ uses : PyO3/maturin-action@v1
462
+ with :
463
+ target : ${{ matrix.target }}
464
+ manylinux : ${{ matrix.manylinux || 'auto' }}
465
+ args : >
466
+ --release
467
+ --out dist
468
+ --interpreter ${{ matrix.interpreter }}
469
+ -- -Cprofile-use=${{ github.workspace }}/merged.profdata
470
+ rust-toolchain : stable
471
+
472
+ - run : ${{ matrix.ls || 'ls -lh' }} dist/
389
473
390
474
- uses : actions/upload-artifact@v3
391
475
with :
392
476
name : pypi_files
393
477
path : dist
394
478
395
479
inspect-pypi-assets :
396
- needs : [build]
480
+ needs : [build, build-sdist, build-pgo ]
397
481
runs-on : ubuntu-latest
398
482
399
483
steps :
@@ -477,7 +561,7 @@ jobs:
477
561
478
562
test-builds-os :
479
563
name : test build on ${{ matrix.os }}
480
- needs : [build]
564
+ needs : [build, build-pgo ]
481
565
482
566
strategy :
483
567
fail-fast : false
@@ -506,8 +590,8 @@ jobs:
506
590
- run : pytest --ignore=tests/test_docstrings.py
507
591
508
592
release :
509
- needs : [test-builds-arch, test-builds-os, check]
510
- if : " success() && startsWith(github.ref, 'refs/tags/')"
593
+ needs : [test-builds-arch, test-builds-os, build-sdist, check]
594
+ if : success() && startsWith(github.ref, 'refs/tags/')
511
595
runs-on : ubuntu-latest
512
596
513
597
steps :
0 commit comments