Skip to content

Commit 8147f2b

Browse files
committed
Make the NumPy/CMake example more concise
Signed-off-by: Michał Górny <[email protected]>
1 parent 1884b9a commit 8147f2b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/how-to/advanced/cross-compilation.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,20 @@ but merely to provide a starting point with some guidelines. Please look at [oth
249249

250250
## Finding NumPy in cross-compiled Python packages using CMake
251251

252-
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:
252+
If you are building a Python extension via CMake with NumPy and you want it to work in
253+
cross-compilation, you need to prepend to the CMake invocation in your build script the following
254+
lines:
253255

254256
```sh
255257
Python_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')"
256-
Python_NumPy_INCLUDE_DIR="$(python -c 'import numpy;print(numpy.get_include())')"
257-
CMAKE_ARGS="${CMAKE_ARGS} -DPython_EXECUTABLE:PATH=${PYTHON}"
258-
CMAKE_ARGS="${CMAKE_ARGS} -DPython_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"
259-
CMAKE_ARGS="${CMAKE_ARGS} -DPython_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}"
260-
CMAKE_ARGS="${CMAKE_ARGS} -DPython3_EXECUTABLE:PATH=${PYTHON}"
261-
CMAKE_ARGS="${CMAKE_ARGS} -DPython3_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"
262-
CMAKE_ARGS="${CMAKE_ARGS} -DPython3_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}"
258+
Python_NumPy_INCLUDE_DIR="$(python -c 'import numpy; print(numpy.get_include())')"
259+
# usually either Python_* or Python3_* lines are sufficient
260+
CMAKE_ARGS+=" -DPython_EXECUTABLE:PATH=${PYTHON}"
261+
CMAKE_ARGS+=" -DPython_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"
262+
CMAKE_ARGS+=" -DPython_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}"
263+
CMAKE_ARGS+=" -DPython3_EXECUTABLE:PATH=${PYTHON}"
264+
CMAKE_ARGS+=" -DPython3_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"
265+
CMAKE_ARGS+=" -DPython3_NumPy_INCLUDE_DIR=${Python_NumPy_INCLUDE_DIR}"
263266
```
264267

265268
<a id="python-cross-compilation"></a>

0 commit comments

Comments
 (0)