Skip to content

Commit

Permalink
apply Boost patch to support building with NumPy 2.X+
Browse files Browse the repository at this point in the history
NumPy 2.0.0 introduced an API change that required a modification in
boost::python:

boostorg/python@0474de0
  • Loading branch information
mattyjams committed Oct 7, 2024
1 parent 99e009d commit 93f42f3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,19 @@ def InstallBoost_Helper(context, force, buildArgs):

with CurrentWorkingDirectory(DownloadURL(BOOST_URL, context, force,
dontExtract=dontExtract)):
# Patch the Boost source in case we're building for NumPy 2.X+.
# This is the change in commit 0474de0 mentioned in the notes above.
PatchFile(
"libs/python/src/numpy/dtype.cpp",
[('int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}',
'''int dtype::get_itemsize() const {
#if NPY_ABI_VERSION < 0x02000000
return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;
#else
return PyDataType_ELSIZE(reinterpret_cast<PyArray_Descr*>(ptr()));
#endif
}''')])

if Windows():
bootstrap = "bootstrap.bat"
else:
Expand Down

0 comments on commit 93f42f3

Please sign in to comment.