Skip to content

Commit

Permalink
Merge pull request #212 from bkpoon/np2_fix_main
Browse files Browse the repository at this point in the history
Add another patch for numpy 2.0 (main branch)
  • Loading branch information
h-vetinari committed Jul 29, 2024
2 parents df19087 + 20bb16c commit 8e31090
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
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: 7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617
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/charconv/pull/183
- patches/0002-Merge-pull-request-183-from-boostorg-ppc64le.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: 3
number: 4
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;
}

namespace

0 comments on commit 8e31090

Please sign in to comment.