From 93f42f32c273214c6c0c1e219ac247013f7d891d Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 27 Jun 2024 19:12:31 -0400 Subject: [PATCH] apply Boost patch to support building with NumPy 2.X+ NumPy 2.0.0 introduced an API change that required a modification in boost::python: https://github.com/boostorg/python/commit/0474de0 --- build_scripts/build_usd.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py index 8cf8dd038f..23d8c32206 100644 --- a/build_scripts/build_usd.py +++ b/build_scripts/build_usd.py @@ -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(ptr())->elsize;}', +'''int dtype::get_itemsize() const { +#if NPY_ABI_VERSION < 0x02000000 + return reinterpret_cast(ptr())->elsize; +#else + return PyDataType_ELSIZE(reinterpret_cast(ptr())); +#endif +}''')]) + if Windows(): bootstrap = "bootstrap.bat" else: