diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-07-28 18:42:30 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-07-28 18:53:02 +0400 |
commit | c85265b4551acbc7adf41f47f612373e42e0176d (patch) | |
tree | 49cbc3a2b1cd0741250946c8b56e0b5d34d55f44 | |
parent | c4b47b89f76d259792b3a8f0f9b6718668996000 (diff) |
Make requests python package to be detected in the same way as numpy
This solves missing requests package reported on the systems where it's
located in dist-packages rather than in site-packages.
To do this there's now a helper macros which handles both requests and
numpy now and could be used for more packages in the future.
Reviewers: campbellbarton
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D686
-rw-r--r-- | CMakeLists.txt | 57 | ||||
-rw-r--r-- | build_files/cmake/macros.cmake | 51 | ||||
-rw-r--r-- | source/creator/CMakeLists.txt | 2 |
3 files changed, 57 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9de92af9a82..9f32f79049b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,11 +257,13 @@ if(UNIX AND NOT APPLE) endif() option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON) option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON) -set(PYTHON_NUMPY_PATH "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module") +set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module") mark_as_advanced(PYTHON_NUMPY_PATH) if(UNIX AND NOT APPLE) option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON) + set(PYTHON_REQUESTS_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'requests' module") + mark_as_advanced(PYTHON_REQUESTS_PATH) endif() # Cycles @@ -2245,62 +2247,13 @@ if(WITH_PYTHON) if(WIN32) # pass, we have this in an archive to extract elseif(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) - # set but invalid - # -- disabled until we make numpy bundled with blender - campbell - if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND)) -# if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy") -# message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' " -# "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python") -# set(WITH_PYTHON_INSTALL_NUMPY OFF) -# endif() - # not set, so initialize - else() - string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}") - list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR) - - # re-cache - unset(PYTHON_NUMPY_PATH CACHE) - find_path(PYTHON_NUMPY_PATH - NAMES - numpy - HINTS - "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/" - "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/" - PATH_SUFFIXES - site-packages - dist-packages - NO_DEFAULT_PATH - ) - - if(NOT EXISTS "${PYTHON_NUMPY_PATH}") - message(WARNING "'numpy' path could not be found in:\n" - "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', " - "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', " - "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', " - "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', " - "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python") - set(WITH_PYTHON_INSTALL_NUMPY OFF) - else() - message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'") - endif() - - unset(_PY_VER_SPLIT) - unset(_PY_VER_MAJOR) - endif() + find_python_package(numpy) endif() if(WIN32 OR APPLE) # pass, we have this in lib/python/site-packages elseif(WITH_PYTHON_INSTALL_REQUESTS) - if(NOT EXISTS ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/requests) - # gets annoying otherwise... - if(FIRST_RUN) - message(WARNING "'requests' path could not be found in:\n" - "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/requests'\n" - "WITH_PYTHON_INSTALL_REQUESTS option will be ignored when installing python") - endif() - set(WITH_PYTHON_INSTALL_REQUESTS OFF) - endif() + find_python_package(requests) endif() endif() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 8890c137dd2..f896fb9d6a9 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1324,3 +1324,54 @@ macro(msgfmt_simple unset(_file_to) unset(_file_to_path) endmacro() + +macro(find_python_package + package) + + string(TOUPPER ${package} _upper_package) + + # set but invalid + if((NOT ${PYTHON_${_upper_package}_PATH} STREQUAL "") AND + (NOT ${PYTHON_${_upper_package}_PATH} MATCHES NOTFOUND)) +# if(NOT EXISTS "${PYTHON_${_upper_package}_PATH}/${package}") +# message(WARNING "PYTHON_${_upper_package}_PATH is invalid, ${package} not found in '${PYTHON_${_upper_package}_PATH}' " +# "WITH_PYTHON_INSTALL_${_upper_package} option will be ignored when installing python") +# set(WITH_PYTHON_INSTALL${_upper_package} OFF) +# endif() + # not set, so initialize + else() + string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}") + list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR) + + # re-cache + unset(PYTHON_${_upper_package}_PATH CACHE) + find_path(PYTHON_${_upper_package}_PATH + NAMES + ${package} + HINTS + "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/" + "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/" + PATH_SUFFIXES + site-packages + dist-packages + NO_DEFAULT_PATH + ) + + if(NOT EXISTS "${PYTHON_${_upper_package}_PATH}") + message(WARNING "'${package}' path could not be found in:\n" + "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${package}', " + "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/${package}', " + "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', " + "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', " + "WITH_PYTHON_INSTALL_${_upper_package} option will be ignored when installing python") + set(WITH_PYTHON_INSTALL_${_upper_package} OFF) + else() + message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'") + endif() + + unset(_PY_VER_SPLIT) + unset(_PY_VER_MAJOR) + endif() + + unset(_upper_package) +endmacro() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 8deadb9c7b7..bd223b8d540 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -539,7 +539,7 @@ if(UNIX AND NOT APPLE) # Copy requests, we need to generalize site-packages if(WITH_PYTHON_INSTALL_REQUESTS) install( - DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/requests + DIRECTORY ${PYTHON_REQUESTS_PATH}/requests DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages PATTERN ".svn" EXCLUDE PATTERN "__pycache__" EXCLUDE # * any cache * |