Skip to content
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

Add another patch for numpy 2.0 (v1.84.x branch) #211

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .scripts/build_steps.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ source:
url: https://boostorg.jfrog.io/artifactory/main/release/{{ version }}/source/boost_{{ version|replace(".", "_") }}.tar.bz2
sha256: cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454
patches:
# ensure our compiler flags get used during bootstrapping
# ensure our compiler flags get used during bootstrapping
- patches/0001-Add-default-value-for-cxx-and-cxxflags-options-for-t.patch
# backport https://github.com/boostorg/locale/pull/212
- patches/0002-Reimplement-string_set-as-any_string.patch
# backport https://github.com/boostorg/python/pull/432
- patches/0003-Support-numpy-2.0.0b1.patch
# backport https://github.com/boostorg/python/pull/443
- patches/0004-Support-numpy-2.0.patch

build:
number: 4
number: 5
script_env:
- PY_DUMMY_VER={{ PY_DUMMY_VER }}
- NP_DUMMY_VER={{ NP_DUMMY_VER }}
Expand Down
38 changes: 38 additions & 0 deletions recipe/patches/0004-Support-numpy-2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/libs/python/src/numpy/dtype.cpp b/libs/python/src/numpy/dtype.cpp
index da30d192..1ce8c6ec 100644
--- a/libs/python/src/numpy/dtype.cpp
+++ b/libs/python/src/numpy/dtype.cpp
@@ -107,32 +107,7 @@ int dtype::get_itemsize() const {
}

bool equivalent(dtype const & a, dtype const & b) {
- // On Windows x64, the behaviour described on
- // http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
- // PyArray_EquivTypes unfortunately does not extend as expected:
- // "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
- // This should also hold for 64-bit platforms (and does on Linux), but not
- // on Windows. Implement an alternative:
-#ifdef _MSC_VER
- if (sizeof(long) == sizeof(int) &&
- // Manually take care of the type equivalence.
- ((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
- (b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
- (a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
- (b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
- return true;
- } else {
- return PyArray_EquivTypes(
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
- reinterpret_cast<PyArray_Descr*>(b.ptr())
- );
- }
-#else
- return PyArray_EquivTypes(
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
- reinterpret_cast<PyArray_Descr*>(b.ptr())
- );
-#endif
+ return a == b;
h-vetinari marked this conversation as resolved.
Show resolved Hide resolved
}

namespace