From 986a688b2561720830d6be293e8e0e5a21bc07b3 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 4 Oct 2024 09:20:49 +0100 Subject: [PATCH] bump MSRV to 1.63 --- .github/workflows/ci.yml | 102 +++++++++++++++++++++++---------------- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/array.rs | 5 +- 4 files changed, 64 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa524f6ef..c2203cafe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ concurrency: cancel-in-progress: true jobs: - lint: runs-on: ubuntu-latest steps: @@ -32,20 +31,48 @@ jobs: fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] - platform: [ - { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }, - { os: "macOS-13", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }, - { os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" }, - ] + platform: + [ + { + os: "ubuntu-latest", + python-architecture: "x64", + rust-target: "x86_64-unknown-linux-gnu", + }, + { + os: "macOS-13", + python-architecture: "x64", + rust-target: "x86_64-apple-darwin", + }, + { + os: "windows-latest", + python-architecture: "x64", + rust-target: "x86_64-pc-windows-msvc", + }, + ] include: # Older versions of CPython are not available for AArch64. - python-version: 3.12 - platform: { os: "macOS-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" } + platform: + { + os: "macOS-latest", + python-architecture: "arm64", + rust-target: "aarch64-apple-darwin", + } # NumPy does not provide pre-built wheels for PyPy on macOS and Windows - python-version: pypy-3.7 - platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" } + platform: + { + os: "ubuntu-latest", + python-architecture: "x64", + rust-target: "x86_64-unknown-linux-gnu", + } - python-version: pypy-3.8 - platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" } + platform: + { + os: "ubuntu-latest", + python-architecture: "x64", + rust-target: "x86_64-unknown-linux-gnu", + } steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -57,20 +84,10 @@ jobs: uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.platform.rust-target }} - - name: Install toml - run: pip install toml - - name: Edit Cargo.toml and enable new resolver - run: | - import toml - cargo_toml = toml.load("Cargo.toml") - cargo_toml["package"]["resolver"] = "2" - with open("Cargo.toml", "w") as f: - toml.dump(cargo_toml, f) - shell: python - name: Test run: | - pip install "numpy" ml_dtypes - cargo test --all-features + pip install "numpy" ml_dtypes + cargo test --all-features # Not on PyPy, because no embedding API if: ${{ !startsWith(matrix.python-version, 'pypy') }} - name: Test example @@ -90,11 +107,24 @@ jobs: fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] - platform: [ - { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }, - { os: "macOS-13", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }, - { os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" }, - ] + platform: + [ + { + os: "ubuntu-latest", + python-architecture: "x64", + rust-target: "x86_64-unknown-linux-gnu", + }, + { + os: "macOS-13", + python-architecture: "x64", + rust-target: "x86_64-apple-darwin", + }, + { + os: "windows-latest", + python-architecture: "x64", + rust-target: "x86_64-pc-windows-msvc", + }, + ] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -106,16 +136,6 @@ jobs: uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.platform.rust-target }} - - name: Install toml - run: pip install toml - - name: Edit Cargo.toml and enable new resolver - run: | - import toml - cargo_toml = toml.load("Cargo.toml") - cargo_toml["package"]["resolver"] = "2" - with open("Cargo.toml", "w") as f: - toml.dump(cargo_toml, f) - shell: python - name: Test run: | pip install "numpy<2" ml_dtypes @@ -149,8 +169,8 @@ jobs: continue-on-error: true - uses: taiki-e/install-action@valgrind - run: | - pip install "numpy" ml_dtypes - cargo test --all-features --release + pip install "numpy" ml_dtypes + cargo test --all-features --release env: CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1 @@ -164,8 +184,8 @@ jobs: continue-on-error: true - uses: taiki-e/install-action@cargo-careful - run: | - pip install "numpy" ml_dtypes - cargo careful test --all-features + pip install "numpy" ml_dtypes + cargo careful test --all-features check-msrv: runs-on: ubuntu-latest @@ -176,7 +196,7 @@ jobs: with: python-version: 3.8 - name: Install Rust - uses: dtolnay/rust-toolchain@1.56.0 + uses: dtolnay/rust-toolchain@1.63 - uses: Swatinem/rust-cache@v2 with: workspaces: examples/simple diff --git a/CHANGELOG.md b/CHANGELOG.md index 05d9d2057..f3719829e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog - Unreleased + - Bump MSRV to 1.63. ([#450](https://github.com/PyO3/rust-numpy/pull/450)) - Add `permute` and `transpose` methods for changing the order of axes of a `PyArray`. ([#428](https://github.com/PyO3/rust-numpy/pull/428)) - Add support for NumPy v2 which had a number of changes to the [C API](https://numpy.org/devdocs/numpy_2_0_migration_guide.html#c-api-changes). ([#442](https://github.com/PyO3/rust-numpy/pull/442)) diff --git a/Cargo.toml b/Cargo.toml index 4c71108a9..38ebf7424 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ authors = [ description = "PyO3-based Rust bindings of the NumPy C-API" documentation = "https://docs.rs/numpy" edition = "2021" -rust-version = "1.56" +rust-version = "1.63" repository = "https://github.com/PyO3/rust-numpy" categories = ["api-bindings", "development-tools::ffi", "science"] keywords = ["python", "numpy", "ffi", "pyo3"] diff --git a/src/array.rs b/src/array.rs index 276c9918a..76d62d1c3 100644 --- a/src/array.rs +++ b/src/array.rs @@ -191,10 +191,7 @@ impl IntoPy for PyArray { impl<'py, T: Element, D: Dimension> FromPyObject<'py> for &'py PyArray { fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - #[allow(clippy::map_clone)] // due to MSRV - PyArray::extract(ob) - .map(Clone::clone) - .map(Bound::into_gil_ref) + PyArray::extract(ob).cloned().map(Bound::into_gil_ref) } }