Skip to content

Commit 30f8a10

Browse files
authored
Merge pull request #211 from bkpoon/np2_fix
Add another patch for numpy 2.0 (v1.84.x branch)
2 parents 0760238 + 5f3c368 commit 30f8a10

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

.scripts/build_steps.sh

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

recipe/meta.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ source:
2424
url: https://boostorg.jfrog.io/artifactory/main/release/{{ version }}/source/boost_{{ version|replace(".", "_") }}.tar.bz2
2525
sha256: cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454
2626
patches:
27-
# ensure our compiler flags get used during bootstrapping
27+
# ensure our compiler flags get used during bootstrapping
2828
- patches/0001-Add-default-value-for-cxx-and-cxxflags-options-for-t.patch
2929
# backport https://github.com/boostorg/locale/pull/212
3030
- patches/0002-Reimplement-string_set-as-any_string.patch
3131
# backport https://github.com/boostorg/python/pull/432
3232
- patches/0003-Support-numpy-2.0.0b1.patch
33+
# backport https://github.com/boostorg/python/pull/443
34+
- patches/0004-Support-numpy-2.0.patch
3335

3436
build:
35-
number: 4
37+
number: 5
3638
script_env:
3739
- PY_DUMMY_VER={{ PY_DUMMY_VER }}
3840
- NP_DUMMY_VER={{ NP_DUMMY_VER }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/libs/python/src/numpy/dtype.cpp b/libs/python/src/numpy/dtype.cpp
2+
index da30d192..1ce8c6ec 100644
3+
--- a/libs/python/src/numpy/dtype.cpp
4+
+++ b/libs/python/src/numpy/dtype.cpp
5+
@@ -107,32 +107,7 @@ int dtype::get_itemsize() const {
6+
}
7+
8+
bool equivalent(dtype const & a, dtype const & b) {
9+
- // On Windows x64, the behaviour described on
10+
- // http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
11+
- // PyArray_EquivTypes unfortunately does not extend as expected:
12+
- // "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
13+
- // This should also hold for 64-bit platforms (and does on Linux), but not
14+
- // on Windows. Implement an alternative:
15+
-#ifdef _MSC_VER
16+
- if (sizeof(long) == sizeof(int) &&
17+
- // Manually take care of the type equivalence.
18+
- ((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
19+
- (b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
20+
- (a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
21+
- (b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
22+
- return true;
23+
- } else {
24+
- return PyArray_EquivTypes(
25+
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
26+
- reinterpret_cast<PyArray_Descr*>(b.ptr())
27+
- );
28+
- }
29+
-#else
30+
- return PyArray_EquivTypes(
31+
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
32+
- reinterpret_cast<PyArray_Descr*>(b.ptr())
33+
- );
34+
-#endif
35+
+ return a == b;
36+
}
37+
38+
namespace

0 commit comments

Comments
 (0)