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