From 71f25cd8528fea07e3b22c185a225e019372201f Mon Sep 17 00:00:00 2001 From: Mirco Marahrens Date: Sat, 1 Feb 2025 18:40:36 +0100 Subject: [PATCH 1/4] fix: findPython --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b17b005..b9c4191 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,9 @@ endif() # Running find_package(PythonInterp) to retrieve the Python version # which is not exported by Pybind11's cmake. # Cf. https://github.com/pybind/pybind11/issues/2268 -find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) +#find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) +# the above line uses a deprecated cmake method, use the following instead +find_package(Python COMPONENTS Interpreter REQUIRED) set(pybind11_REQUIRED_VERSION 2.6.1) if(TARGET pybind11 OR TARGET pybind11::headers) From c53d15ca7f5cbd041fbb3aad2111a32f38fe562e Mon Sep 17 00:00:00 2001 From: Mirco Marahrens Date: Sat, 1 Feb 2025 19:33:10 +0100 Subject: [PATCH 2/4] fix: Numpy include dir --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9c4191..3125a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,10 +65,10 @@ endif() # Look for NumPy headers, except if NUMPY_INCLUDE_DIRS is passed, # which is required under some circumstances (such as wasm, where # there is no real python executable) -if(NOT NUMPY_INCLUDE_DIRS) +if(NOT Python_NumPy_INCLUDE_DIR) find_package(NumPy REQUIRED) endif() -message(STATUS "Found numpy: ${NUMPY_INCLUDE_DIRS}") +message(STATUS "Found numpy: ${Python_NumPy_INCLUDE_DIR}") # Build # ===== From e8e31666edf10d9968acb9de50a06405046d6146 Mon Sep 17 00:00:00 2001 From: Mirco Marahrens Date: Sun, 2 Feb 2025 00:17:59 +0100 Subject: [PATCH 3/4] fix: numpy --- CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3125a67..816ab2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ endif() # Cf. https://github.com/pybind/pybind11/issues/2268 #find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) # the above line uses a deprecated cmake method, use the following instead -find_package(Python COMPONENTS Interpreter REQUIRED) +find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED) set(pybind11_REQUIRED_VERSION 2.6.1) if(TARGET pybind11 OR TARGET pybind11::headers) @@ -62,12 +62,6 @@ else() message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS}/pybind11") endif() -# Look for NumPy headers, except if NUMPY_INCLUDE_DIRS is passed, -# which is required under some circumstances (such as wasm, where -# there is no real python executable) -if(NOT Python_NumPy_INCLUDE_DIR) - find_package(NumPy REQUIRED) -endif() message(STATUS "Found numpy: ${Python_NumPy_INCLUDE_DIR}") # Build @@ -87,7 +81,7 @@ set(XTENSOR_PYTHON_HEADERS add_library(xtensor-python INTERFACE) target_include_directories(xtensor-python INTERFACE - "$" + "$" $) target_link_libraries(xtensor-python INTERFACE xtensor) get_target_property(inc_dir xtensor-python INTERFACE_INCLUDE_DIRECTORIES) From 43b71fed4e2f67db4083773db8a6fceb74a78597 Mon Sep 17 00:00:00 2001 From: Mirco Marahrens Date: Tue, 13 May 2025 20:46:13 +0200 Subject: [PATCH 4/4] fix --- cmake/FindNumPy.cmake | 89 ------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 cmake/FindNumPy.cmake diff --git a/cmake/FindNumPy.cmake b/cmake/FindNumPy.cmake deleted file mode 100644 index f043566..0000000 --- a/cmake/FindNumPy.cmake +++ /dev/null @@ -1,89 +0,0 @@ -# - Find the NumPy libraries -# This module finds if NumPy is installed, and sets the following variables -# indicating where it is. -# -# TODO: Update to provide the libraries and paths for linking npymath lib. -# -# NUMPY_FOUND - was NumPy found -# NUMPY_VERSION - the version of NumPy found as a string -# NUMPY_VERSION_MAJOR - the major version number of NumPy -# NUMPY_VERSION_MINOR - the minor version number of NumPy -# NUMPY_VERSION_PATCH - the patch version number of NumPy -# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 -# NUMPY_INCLUDE_DIRS - path to the NumPy include files - -#============================================================================ -# Copyright 2012 Continuum Analytics, Inc. -# -# MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -# -#============================================================================ - -# Finding NumPy involves calling the Python interpreter -if(NumPy_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) -else() - find_package(PythonInterp) -endif() - -if(NOT PYTHONINTERP_FOUND) - set(NUMPY_FOUND FALSE) -endif() - -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy as n; print(n.__version__); print(n.get_include());" - RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS - OUTPUT_VARIABLE _NUMPY_VALUES - ERROR_VARIABLE _NUMPY_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) - if(NumPy_FIND_REQUIRED) - message(FATAL_ERROR - "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") - endif() - set(NUMPY_FOUND FALSE) -endif() - -# Convert the process output into a list -string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES}) -string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) -list(GET _NUMPY_VALUES 0 NUMPY_VERSION) -list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) - -# Make sure all directory separators are '/' -string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) - -# Get the major and minor version numbers -string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) -list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) -list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) -list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) -string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) -math(EXPR NUMPY_VERSION_DECIMAL - "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") - -find_package_message(NUMPY - "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" - "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") - -set(NUMPY_FOUND TRUE)