diff --git a/CMakeLists.txt b/CMakeLists.txt index 0166553..1aedd4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ cgrowth_get_color_flags() IF ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) # set discovered python local folder - cmake_path(SET PY_LOCAL_DIR "${PY_LOCAL_DIR}") + string(REGEX REPLACE "\\\\" "/" PY_LOCAL_DIR ${PY_LOCAL_DIR}) set( Python3_INSTALL_DIR "${PY_LOCAL_DIR}" ) set( Python3_INSTALL_DIR "${PY_LOCAL_DIR}" CACHE STRING "python install dir" FORCE) @@ -93,7 +93,9 @@ IF ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) # get local user library folder as default install prefix () if (Python3_EXECUTABLE MATCHES "conda") - cmake_path(SET CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}") + set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}") + elseif (EXISTS $ENV{VIRTUAL_ENV}) + set(CMAKE_INSTALL_PREFIX "$ENV{VIRTUAL_ENV}") else () execute_process(COMMAND ${Python3_EXECUTABLE} -m site --user-base OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) endif () @@ -109,7 +111,7 @@ IF ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) endif () endif () - cmake_path(SET CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + string(REGEX REPLACE "\\\\" "/" CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) # cache it set( CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install prefix" FORCE) @@ -119,7 +121,7 @@ ELSEIF ( ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local") AND NOT ("$CACHE{CMAK ELSE () # make sure we get the absolute path get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) - cmake_path(SET CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + string(REGEX REPLACE "\\\\" "/" CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) ENDIF () # set libraries in binaries installation directories diff --git a/cmake/ProcessOptions.cmake b/cmake/ProcessOptions.cmake index 6fb9b9c..594b4d2 100644 --- a/cmake/ProcessOptions.cmake +++ b/cmake/ProcessOptions.cmake @@ -132,6 +132,8 @@ function( CGROWTH_PROCESS_WITH_PYTHON ) set( HAVE_PYTHON OFF PARENT_SCOPE ) string(REGEX MATCH "^3([.][0-9]+)?" VALID_PYVERSION "${with-python}" ) + set(Python_FIND_VIRTUALENV FIRST) + if ( ${with-python} STREQUAL "ON" OR VALID_PYVERSION OR EXISTS ${with-python} ) # Localize the Python interpreter @@ -145,7 +147,7 @@ print('.'.join(str(v) for v in sys.version_info)); print(sys.prefix); print(s.get_python_inc(plat_specific=True)); print(s.get_python_lib(plat_specific=True)); -print(s.get_config_var('SO')); +print(s.get_config_var('EXT_SUFFIX')); print(hasattr(sys, 'gettotalrefcount')+0); print(struct.calcsize('@P')); print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); @@ -217,13 +219,13 @@ print(s.get_config_var('MULTIARCH') or ''); endif () # set local install dir for python packages - if (Python3_EXECUTABLE MATCHES "conda") + if (Python3_EXECUTABLE MATCHES "conda" OR EXISTS "$ENV{VIRTUAL_ENV}") execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print([v for v in site.getsitepackages() if v.endswith('site-packages')][0])" OUTPUT_VARIABLE PY_LOCAL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) else () execute_process(COMMAND ${Python3_EXECUTABLE} -m site --user-site OUTPUT_VARIABLE PY_LOCAL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) endif () - cmake_path(SET PY_LOCAL_DIR "${PY_LOCAL_DIR}") + string(REGEX REPLACE "\\\\" "/" PY_LOCAL_DIR ${PY_LOCAL_DIR}) # create the directory if it does not exist file(MAKE_DIRECTORY "${PY_LOCAL_DIR}")