Skip to content

Commit

Permalink
Merge pull request #146 from hmaarrfk/patch-1
Browse files Browse the repository at this point in the history
use new style find python
  • Loading branch information
constantinpape authored Oct 17, 2024
2 parents 7ff36af + 2d8e5cc commit 146c6cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
2 changes: 1 addition & 1 deletion conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cmake .. -G "%CMAKE_GENERATOR%" -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
^
%OPTIMIZER_ARGS% ^
^
-DPYTHON_EXECUTABLE=%PYTHON% ^
-DPython_EXECUTABLE=%PYTHON% ^
-DBUILD_NIFTY_PYTHON=yes ^
-DBUILD_CPP_TEST=no ^
-DBUILD_CPP_EXAMPLES=no ^
Expand Down
5 changes: 1 addition & 4 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export PY_INSTALL_DIR="${PREFIX}/lib/python3.7/site-packages"

##
## START THE BUILD
##
Expand All @@ -13,7 +11,6 @@ cmake . \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_PREFIX_PATH="${PREFIX}" \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DPYTHON_MODULE_INSTALL_DIR="${PY_INSTALL_DIR}" \
\
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
\
Expand All @@ -25,7 +22,7 @@ cmake . \
-DWITH_BOOST_FS=OFF \
\
-DBUILD_NIFTY_PYTHON=ON \
-DPYTHON_EXECUTABLE="${PYTHON}" \
-DPython_EXECUTABLE="${PYTHON}" \
##

##
Expand Down
39 changes: 3 additions & 36 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,11 @@ else()
endif()
message(STATUS "Using c++ 17 for pybind")

find_package(NUMPY REQUIRED)
include_directories(${NUMPY_INCLUDE_DIRS})

find_package(Python 3 REQUIRED COMPONENTS NumPy)
include_directories(${Python_NumPy_INCLUDE_DIRS})

add_subdirectory(test)
add_subdirectory(lib)


#################################
# INSTALL THE PYTHON MODULE
#################################

IF(NOT DEFINED PYTHON_MODULE_INSTALL_DIR OR PYTHON_MODULE_INSTALL_DIR MATCHES "^$")


execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"from __future__ import print_function; from distutils import sysconfig as sc; print(sc.get_python_lib(prefix='', plat_specific=True))"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "from __future__ import print_function; from distutils.sysconfig import get_python_lib; print(get_python_lib())"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)

SET(PYTHON_MODULE_INSTALL_DIR ${PYTHON_SITE})

ENDIF()

SET(PYTHON_MODULE_INSTALL_DIR ${PYTHON_MODULE_INSTALL_DIR}
CACHE PATH "where to install the Nifty Python package" FORCE)

# this is the install path relative to CMAKE_INSTALL_PREFIX,
# use this in INSTALL() commands to get packaging right
FILE(RELATIVE_PATH PYTHON_MODULE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_MODULE_INSTALL_DIR})



install(DIRECTORY ${CMAKE_BINARY_DIR}/python/nifty
DESTINATION ${PYTHON_MODULE_INSTALL_DIR})
DESTINATION ${Python_SITELIB})

0 comments on commit 146c6cc

Please sign in to comment.