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