@@ -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,18 +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
382
+
364
383
# generate self-schema now, so we don't have to do so inside docker in maturin build
365
384
- run : python generate_self_schema.py
366
385
367
- - name : build sdist
368
- if : ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux == 'auto' }}
369
- uses : PyO3/maturin-action@v1
370
- with :
371
- command : sdist
372
- args : --out dist
373
- rust-toolchain : stable
374
-
375
386
- name : build wheels
376
387
uses : PyO3/maturin-action@v1
377
388
with :
@@ -383,15 +394,87 @@ jobs:
383
394
384
395
- run : ${{ matrix.ls || 'ls -lh' }} dist/
385
396
386
- - run : twine check --strict dist/*
397
+ - uses : actions/upload-artifact@v3
398
+ with :
399
+ name : pypi_files
400
+ path : dist
401
+
402
+ build-pgo :
403
+ name : build pgo-optimized on ${{ matrix.platform || matrix.os }} (${{ matrix.interpreter}} - ${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
404
+ # only run on push to main and on release
405
+ if : startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
406
+ strategy :
407
+ fail-fast : false
408
+ matrix :
409
+ os : [ubuntu]
410
+ platform : [linux]
411
+ target : [x86_64]
412
+ manylinux : [auto]
413
+ interpreter : ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
414
+
415
+ runs-on : ${{ matrix.os }}-latest
416
+ steps :
417
+ - uses : actions/checkout@v3
418
+
419
+ - name : set up python
420
+ uses : actions/setup-python@v4
421
+ with :
422
+ python-version : ${{ matrix.interpreter }}
423
+ architecture : ${{ matrix.python-architecture || 'x64' }}
424
+
425
+ - name : install rust stable
426
+ id : rust-toolchain
427
+ uses : dtolnay/rust-toolchain@stable
428
+ with :
429
+ components : llvm-tools
430
+
431
+ - run : pip install -U 'black>=22.3.0,<23' typing_extensions
432
+
433
+ # generate self-schema now, so we don't have to do so inside docker in maturin build
434
+ - run : python generate_self_schema.py
435
+
436
+ - name : build initial wheel
437
+ uses : PyO3/maturin-action@v1
438
+ with :
439
+ target : ${{ matrix.target }}
440
+ manylinux : ${{ matrix.manylinux || 'auto' }}
441
+ args : >
442
+ --release
443
+ --out pgo-wheel
444
+ --interpreter ${{ matrix.interpreter }}
445
+ -- -Cprofile-generate=${{ github.workspace }}/profdata
446
+ rust-toolchain : stable
447
+
448
+ - name : generate pgo data
449
+ run : |
450
+ pip install -U pip
451
+ pip install -r tests/requirements.txt
452
+ pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
453
+ cd tests # change directory to avoid importing local pydantic_core source
454
+ pytest
455
+ 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'
456
+
457
+ - name : build pgo-optimized wheel
458
+ uses : PyO3/maturin-action@v1
459
+ with :
460
+ target : ${{ matrix.target }}
461
+ manylinux : ${{ matrix.manylinux || 'auto' }}
462
+ args : >
463
+ --release
464
+ --out dist
465
+ --interpreter ${{ matrix.interpreter }}
466
+ -- -Cprofile-use=${{ github.workspace }}/merged.profdata
467
+ rust-toolchain : stable
468
+
469
+ - run : ${{ matrix.ls || 'ls -lh' }} dist/
387
470
388
471
- uses : actions/upload-artifact@v3
389
472
with :
390
473
name : pypi_files
391
474
path : dist
392
475
393
476
inspect-pypi-assets :
394
- needs : [build]
477
+ needs : [build, build-sdist, build-pgo ]
395
478
runs-on : ubuntu-latest
396
479
397
480
steps :
@@ -475,7 +558,7 @@ jobs:
475
558
476
559
test-builds-os :
477
560
name : test build on ${{ matrix.os }}
478
- needs : [build]
561
+ needs : [build, build-pgo ]
479
562
480
563
strategy :
481
564
fail-fast : false
@@ -504,8 +587,8 @@ jobs:
504
587
- run : pytest --ignore=tests/test_docstrings.py
505
588
506
589
release :
507
- needs : [test-builds-arch, test-builds-os, check]
508
- if : " success() && startsWith(github.ref, 'refs/tags/')"
590
+ needs : [test-builds-arch, test-builds-os, build-sdist, check]
591
+ if : success() && startsWith(github.ref, 'refs/tags/')
509
592
runs-on : ubuntu-latest
510
593
511
594
steps :
0 commit comments