forked from pybind/pybind11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make
numpy.h
compatible with both NumPy 1.x and 2.x (pybind#5050
) * API: Make `numpy.h` compatible with both NumPy 1.x and 2.x * TST: Update numpy dtype flags test to not covert flags to char * API: Add `numpy2.h` instead and make `numpy.h` safe This means that users of `numpy.h` cannot be broken, but need to update to `numpy2.h` if they want to compile for NumPy 2. Using Macros simply and didn't bother to try to remove unnecessary code paths. * API: Rather than `numpy2.h` use a define for the user. * Thread `PYBIND11_NUMPY2_SUPPORT` through things and try to adept test matrix * Small fixups (shouldn't matter)? * Fixup. Does upgrading scipy help? (it shouldn't?) (Some other small fixup) * Use NumPy 2 nightlies for ubuntu-latest job also * BUG: Fix numpy.bool check * TST: Fix complexwarning * BUG: Fix the fact that only the 50 slot is filled with the copy alias (There were 3 functions all doing the same, only this slot survived 2.x) * TST: One more test tweak * TST: Use "long" name for long, since it changed on windows * TST: Apparently we didn't always have ulong, so just use `L` * TST: Enforce dtype='l' for test as default isn't long anymore on windows * Rename macro and invert logic to PYBIND11_NUMPY_1_ONLY * PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED * Test and code comment expansion * CI: Use pre-releases of numpy/scipy from pip via explicit version * CI: NumPy 2 only available on almalinux (as it is Python >=3.9) * MAINT: Match name more exactly and adopt error phrasing * MAINT: Pushed early, move helper to be private member * fix error message compilation when using NumPy 1.x-only backcompat * silence name shadowing warning * chore: minor optimization Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Ralf W. Grosse-Kunstleve <[email protected]> Co-authored-by: Henry Schreiner <[email protected]>
- Loading branch information
1 parent
e0f2c71
commit 705efcc
Showing
11 changed files
with
206 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,12 +108,14 @@ jobs: | |
run: python -m pip install pytest-github-actions-annotate-failures | ||
|
||
# First build - C++11 mode and inplace | ||
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON here. | ||
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON here | ||
# (same for PYBIND11_NUMPY_1_ONLY, but requires a NumPy 1.x at runtime). | ||
- name: Configure C++11 ${{ matrix.args }} | ||
run: > | ||
cmake -S . -B . | ||
-DPYBIND11_WERROR=ON | ||
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON | ||
-DPYBIND11_NUMPY_1_ONLY=ON | ||
-DDOWNLOAD_CATCH=ON | ||
-DDOWNLOAD_EIGEN=ON | ||
-DCMAKE_CXX_STANDARD=11 | ||
|
@@ -138,11 +140,13 @@ jobs: | |
|
||
# Second build - C++17 mode and in a build directory | ||
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF here. | ||
# (same for PYBIND11_NUMPY_1_ONLY, but requires a NumPy 1.x at runtime). | ||
- name: Configure C++17 | ||
run: > | ||
cmake -S . -B build2 | ||
-DPYBIND11_WERROR=ON | ||
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF | ||
-DPYBIND11_NUMPY_1_ONLY=ON | ||
-DDOWNLOAD_CATCH=ON | ||
-DDOWNLOAD_EIGEN=ON | ||
-DCMAKE_CXX_STANDARD=17 | ||
|
@@ -660,6 +664,11 @@ jobs: | |
run: | | ||
python3 -m pip install cmake -r tests/requirements.txt | ||
- name: Ensure NumPy 2 is used (required Python >= 3.9) | ||
if: matrix.container == 'almalinux:9' | ||
run: | | ||
python3 -m pip install 'numpy>=2.0.0b1' 'scipy>=1.13.0rc1' | ||
- name: Configure | ||
shell: bash | ||
run: > | ||
|
@@ -895,8 +904,10 @@ jobs: | |
python-version: ${{ matrix.python }} | ||
|
||
- name: Prepare env | ||
# Ensure use of NumPy 2 (via NumPy nightlies but can be changed soon) | ||
run: | | ||
python3 -m pip install -r tests/requirements.txt | ||
python3 -m pip install 'numpy>=2.0.0b1' 'scipy>=1.13.0rc1' | ||
- name: Update CMake | ||
uses: jwlawson/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.