Skip to content

Commit

Permalink
Merge branch 'main' into slice_index
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpute authored Apr 2, 2024
2 parents 854d762 + c1f11fb commit 7bfb6ec
Show file tree
Hide file tree
Showing 382 changed files with 14,362 additions and 6,744 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contact_links:
about: Ask and answer questions about PyO3 on Discussions
- name: 🔧 Troubleshooting
url: https://github.com/PyO3/pyo3/discussions
about: For troubleshooting help, see the Discussions
about: For troubleshooting help, see the Discussions
- name: 👋 Chat
url: https://gitter.im/PyO3/Lobby
about: Engage with PyO3's users and developers on Gitter
url: https://discord.gg/33kcChzH7f
about: Engage with PyO3's users and developers on Discord
15 changes: 8 additions & 7 deletions .github/workflows/benches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
# performance analysis in order to generate initial data.
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}-benches
cancel-in-progress: true

jobs:
benchmarks:
runs-on: ubuntu-latest
Expand All @@ -19,14 +23,11 @@ jobs:
with:
components: rust-src

- uses: actions/cache@v4
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
pyo3-benches/target
target
key: cargo-${{ runner.os }}-bench-${{ hashFiles('**/Cargo.toml') }}
workspaces: |
.
pyo3-benches
continue-on-error: true

- name: Install cargo-codspeed
Expand Down
74 changes: 11 additions & 63 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
build:
continue-on-error: ${{ endsWith(inputs.python-version, '-dev') || contains(fromJSON('["3.7", "pypy3.7"]'), inputs.python-version) || inputs.rust == 'beta' || inputs.rust == 'nightly' }}
runs-on: ${{ inputs.os }}
if: ${{ !(startsWith(inputs.python-version, 'graalpy') && startsWith(inputs.os, 'windows')) }}
steps:
- uses: actions/checkout@v4

Expand All @@ -47,8 +48,7 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
key: cargo-${{ inputs.python-architecture }}
continue-on-error: true
save-if: ${{ github.event_name != 'merge_group' }}

- if: inputs.os == 'ubuntu-latest'
name: Prepare LD_LIBRARY_PATH (Ubuntu only)
Expand All @@ -66,6 +66,7 @@ jobs:
run: nox -s docs

- name: Build (no features)
if: ${{ !startsWith(inputs.python-version, 'graalpy') }}
run: cargo build --lib --tests --no-default-features

# --no-default-features when used with `cargo build/test -p` doesn't seem to work!
Expand All @@ -75,7 +76,7 @@ jobs:
cargo build --no-default-features
# Run tests (except on PyPy, because no embedding API).
- if: ${{ !startsWith(inputs.python-version, 'pypy') }}
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
name: Test (no features)
run: cargo test --no-default-features --lib --tests

Expand All @@ -86,24 +87,25 @@ jobs:
cargo test --no-default-features
- name: Build (all additive features)
if: ${{ !startsWith(inputs.python-version, 'graalpy') }}
run: cargo build --lib --tests --no-default-features --features "full ${{ inputs.extra-features }}"

- if: ${{ startsWith(inputs.python-version, 'pypy') }}
name: Build PyPy (abi3-py37)
run: cargo build --lib --tests --no-default-features --features "abi3-py37 full ${{ inputs.extra-features }}"

# Run tests (except on PyPy, because no embedding API).
- if: ${{ !startsWith(inputs.python-version, 'pypy') }}
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
name: Test
run: cargo test --no-default-features --features "full ${{ inputs.extra-features }}"

# Run tests again, but in abi3 mode
- if: ${{ !startsWith(inputs.python-version, 'pypy') }}
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
name: Test (abi3)
run: cargo test --no-default-features --features "abi3 full ${{ inputs.extra-features }}"

# Run tests again, for abi3-py37 (the minimal Python version)
- if: ${{ (!startsWith(inputs.python-version, 'pypy')) && (inputs.python-version != '3.7') }}
- if: ${{ (!startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy')) && (inputs.python-version != '3.7') }}
name: Test (abi3-py37)
run: cargo test --no-default-features --features "abi3-py37 full ${{ inputs.extra-features }}"

Expand All @@ -119,9 +121,9 @@ jobs:
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
# pypy 3.7 and 3.8 are not PEP 3123 compliant so fail checks here
if: ${{ inputs.rust == 'stable' && inputs.python-version != 'pypy3.7' && inputs.python-version != 'pypy3.8' }}
if: ${{ inputs.rust == 'stable' && inputs.python-version != 'pypy3.7' && inputs.python-version != 'pypy3.8' && !startsWith(inputs.python-version, 'graalpy') }}
id: ffi-changes
with:
base: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }}
Expand All @@ -136,63 +138,9 @@ jobs:
- name: Run pyo3-ffi-check
# pypy 3.7 and 3.8 are not PEP 3123 compliant so fail checks here, nor
# is pypy 3.9 on windows
if: ${{ endsWith(inputs.python-version, '-dev') || (steps.ffi-changes.outputs.changed == 'true' && inputs.rust == 'stable' && inputs.python-version != 'pypy3.7' && inputs.python-version != 'pypy3.8' && !(inputs.python-version == 'pypy3.9' && contains(inputs.os, 'windows'))) }}
if: ${{ endsWith(inputs.python-version, '-dev') || (steps.ffi-changes.outputs.changed == 'true' && inputs.rust == 'stable' && inputs.python-version != 'pypy3.7' && inputs.python-version != 'pypy3.8' && !startsWith(inputs.python-version, 'graalpy') && !(inputs.python-version == 'pypy3.9' && contains(inputs.os, 'windows'))) }}
run: nox -s ffi-check


- name: Test cross compilation
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }}
uses: PyO3/maturin-action@v1
env:
PYO3_CROSS_LIB_DIR: /opt/python/cp39-cp39/lib
with:
target: aarch64-unknown-linux-gnu
manylinux: auto
args: --release -i python3.9 -m examples/maturin-starter/Cargo.toml

- run: sudo rm -rf examples/maturin-starter/target
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }}
- name: Test cross compile to same architecture
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.9' }}
uses: PyO3/maturin-action@v1
env:
PYO3_CROSS_LIB_DIR: /opt/python/cp39-cp39/lib
with:
target: x86_64-unknown-linux-gnu
manylinux: auto
args: --release -i python3.9 -m examples/maturin-starter/Cargo.toml

- name: Test cross compilation
if: ${{ inputs.os == 'macos-latest' && inputs.python-version == '3.9' }}
uses: PyO3/maturin-action@v1
with:
target: aarch64-apple-darwin
args: --release -i python3.9 -m examples/maturin-starter/Cargo.toml

- name: Test cross compile to Windows
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.8' }}
env:
XWIN_ARCH: x86_64
run: |
set -ex
sudo apt-get install -y mingw-w64 llvm
rustup target add x86_64-pc-windows-gnu x86_64-pc-windows-msvc
pip install cargo-xwin
# abi3
cargo build --manifest-path examples/maturin-starter/Cargo.toml --features abi3 --target x86_64-pc-windows-gnu
cargo xwin build --manifest-path examples/maturin-starter/Cargo.toml --features abi3 --target x86_64-pc-windows-msvc
# non-abi3
export PYO3_CROSS_PYTHON_VERSION=3.9
cargo build --manifest-path examples/maturin-starter/Cargo.toml --features generate-import-lib --target x86_64-pc-windows-gnu
cargo xwin build --manifest-path examples/maturin-starter/Cargo.toml --features generate-import-lib --target x86_64-pc-windows-msvc
- name: Test cross compile to Windows with maturin
if: ${{ inputs.os == 'ubuntu-latest' && inputs.python-version == '3.8' }}
uses: PyO3/maturin-action@v1
with:
target: x86_64-pc-windows-gnu
args: -i python3.8 -m examples/maturin-starter/Cargo.toml --features abi3

env:
CARGO_TERM_VERBOSE: true
CARGO_BUILD_TARGET: ${{ inputs.rust-target }}
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/cache-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI Cache Cleanup
on:
pull_request_target:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete -R $REPO -B $BRANCH --confirm -- $cacheKey
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
Loading

0 comments on commit 7bfb6ec

Please sign in to comment.