From 1ec2a31dfa48d187662ac3a1e156aaeaad6639d4 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 1 Oct 2024 12:39:56 +0200 Subject: [PATCH 1/3] Document how to find NumPy with CMake on cross-compiled builds --- docs/maintainer/knowledge_base.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/maintainer/knowledge_base.md b/docs/maintainer/knowledge_base.md index 144e0f9cc0..4b904e7133 100644 --- a/docs/maintainer/knowledge_base.md +++ b/docs/maintainer/knowledge_base.md @@ -559,6 +559,21 @@ fi There are more variations of this approach in the wild. So this is not meant to be exhaustive, but merely to provide a starting point with some guidelines. Please look at [other recipes for more examples](https://github.com/search?q=org%3Aconda-forge+path%3Arecipe%2Fmeta.yaml+%22%5Bbuild_platform+%21%3D+target_platform%5D%22&type=code). +#### Finding NumPy in cross-compiled Python packages using CMake + +If you are building a Python extension via CMake with NumPy and you want it work in cross-compilation, you need to preprend to the CMake invocation in your build script the following lines: + +~~~sh +Python_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')" +Python_NumPy_INCLUDE_DIR="$(python -c 'import numpy;print(numpy.get_include())')" +CMAKE_ARGS="${CMAKE_ARGS} -DPython_EXECUTABLE:PATH=${PYTHON}" +CMAKE_ARGS="${CMAKE_ARGS} -DPython_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}" +CMAKE_ARGS="${CMAKE_ARGS} -DPython_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}" +CMAKE_ARGS="${CMAKE_ARGS} -DPython3_EXECUTABLE:PATH=${PYTHON}" +CMAKE_ARGS="${CMAKE_ARGS} -DPython3_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}" +CMAKE_ARGS="${CMAKE_ARGS} -DPython3_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}" +~~~ + From 9d4894ab22d321c737bc46055e4f3b6e8c6eee62 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:11:48 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/maintainer/knowledge_base.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/maintainer/knowledge_base.md b/docs/maintainer/knowledge_base.md index 4b904e7133..9293413fec 100644 --- a/docs/maintainer/knowledge_base.md +++ b/docs/maintainer/knowledge_base.md @@ -561,9 +561,9 @@ but merely to provide a starting point with some guidelines. Please look at [oth #### Finding NumPy in cross-compiled Python packages using CMake -If you are building a Python extension via CMake with NumPy and you want it work in cross-compilation, you need to preprend to the CMake invocation in your build script the following lines: +If you are building a Python extension via CMake with NumPy and you want it work in cross-compilation, you need to preprend to the CMake invocation in your build script the following lines: -~~~sh +```sh Python_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')" Python_NumPy_INCLUDE_DIR="$(python -c 'import numpy;print(numpy.get_include())')" CMAKE_ARGS="${CMAKE_ARGS} -DPython_EXECUTABLE:PATH=${PYTHON}" @@ -572,7 +572,7 @@ CMAKE_ARGS="${CMAKE_ARGS} -DPython_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR} CMAKE_ARGS="${CMAKE_ARGS} -DPython3_EXECUTABLE:PATH=${PYTHON}" CMAKE_ARGS="${CMAKE_ARGS} -DPython3_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}" CMAKE_ARGS="${CMAKE_ARGS} -DPython3_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}" -~~~ +``` From 9bc3bc47beb75c051d1f2a6a5da76a3964c068e9 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Wed, 2 Oct 2024 10:19:23 +0200 Subject: [PATCH 3/3] Update docs/maintainer/knowledge_base.md Co-authored-by: jaimergp --- docs/maintainer/knowledge_base.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/maintainer/knowledge_base.md b/docs/maintainer/knowledge_base.md index 9293413fec..930c94703d 100644 --- a/docs/maintainer/knowledge_base.md +++ b/docs/maintainer/knowledge_base.md @@ -561,7 +561,7 @@ but merely to provide a starting point with some guidelines. Please look at [oth #### Finding NumPy in cross-compiled Python packages using CMake -If you are building a Python extension via CMake with NumPy and you want it work in cross-compilation, you need to preprend to the CMake invocation in your build script the following lines: +If you are building a Python extension via CMake with NumPy and you want it work in cross-compilation, you need to prepend to the CMake invocation in your build script the following lines: ```sh Python_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')"