-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Make numpy.h
compatible with both NumPy 1.x and 2.x
#5050
Merged
Merged
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3c45949
API: Make `numpy.h` compatible with both NumPy 1.x and 2.x
seberg 9116d69
TST: Update numpy dtype flags test to not covert flags to char
seberg ea9ba5f
API: Add `numpy2.h` instead and make `numpy.h` safe
seberg 4555280
API: Rather than `numpy2.h` use a define for the user.
seberg 0d585db
Thread `PYBIND11_NUMPY2_SUPPORT` through things and try to adept test…
seberg 0a87436
Small fixups (shouldn't matter)?
seberg 25df74c
Fixup. Does upgrading scipy help? (it shouldn't?)
seberg f0457a5
Use NumPy 2 nightlies for ubuntu-latest job also
seberg 247d5c3
BUG: Fix numpy.bool check
seberg 5368842
TST: Fix complexwarning
seberg 96157d6
BUG: Fix the fact that only the 50 slot is filled with the copy alias
seberg 6daf11a
TST: One more test tweak
seberg 5cf73bc
TST: Use "long" name for long, since it changed on windows
seberg a6414ff
TST: Apparently we didn't always have ulong, so just use `L`
seberg 79393f5
TST: Enforce dtype='l' for test as default isn't long anymore on windows
seberg 2514af5
Rename macro and invert logic to PYBIND11_NUMPY_1_ONLY
seberg 242300d
PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
a6b2e11
Test and code comment expansion
seberg 99b785a
CI: Use pre-releases of numpy/scipy from pip via explicit version
seberg 525310f
CI: NumPy 2 only available on almalinux (as it is Python >=3.9)
seberg 8d718ff
MAINT: Match name more exactly and adopt error phrasing
seberg e2e923d
MAINT: Pushed early, move helper to be private member
seberg c4bd0e0
fix error message compilation when using NumPy 1.x-only backcompat
seberg 38f8ead
silence name shadowing warning
seberg f3af194
chore: minor optimization
henryiii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_NUMPY2_SUPPORT). | ||
- name: Configure C++11 ${{ matrix.args }} | ||
run: > | ||
cmake -S . -B . | ||
-DPYBIND11_WERROR=ON | ||
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON | ||
-DPYBIND11_NUMPY2_SUPPORT=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_NUMPY2_SUPPORT, 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_NUMPY2_SUPPORT=OFF | ||
-DDOWNLOAD_CATCH=ON | ||
-DDOWNLOAD_EIGEN=ON | ||
-DCMAKE_CXX_STANDARD=17 | ||
|
@@ -895,8 +899,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 --upgrade --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think both are on regular PyPI now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, plus I keep forgetting that |
||
|
||
- name: Update CMake | ||
uses: jwlawson/[email protected] | ||
|
@@ -905,6 +911,7 @@ jobs: | |
run: > | ||
cmake -S . -B build | ||
-DPYBIND11_WERROR=ON | ||
-DPYBIND11_NUMPY2_SUPPORT=ON | ||
-DDOWNLOAD_CATCH=ON | ||
-DDOWNLOAD_EIGEN=ON | ||
-DCMAKE_CXX_STANDARD=20 | ||
|
@@ -925,6 +932,7 @@ jobs: | |
run: > | ||
cmake -S . -B build_partial | ||
-DPYBIND11_WERROR=ON | ||
-DPYBIND11_NUMPY2_SUPPORT=ON | ||
-DDOWNLOAD_CATCH=ON | ||
-DDOWNLOAD_EIGEN=ON | ||
-DCMAKE_CXX_STANDARD=20 | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have an explicit version check here? To make sure that numpy 2 actually gets installed / got installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure