|
1 | 1 | if(PY_EXE) |
2 | 2 |
|
3 | | - #just wholesale copy the entire python source directory into the build directory |
4 | | - #because the pythonic wizards who wrote setuptools like to pollute the source |
5 | | - #directory with egg.info garbage |
6 | | - if( NOT ("${CMAKE_CURRENT_SOURCE_DIR}/" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/" ) ) |
7 | | - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") |
8 | | - endif() |
9 | | - |
10 | | - set(abs_srcdir "${CMAKE_CURRENT_BINARY_DIR}") |
11 | | - |
12 | | - # add_custom_target( hops4py_copy_src ALL |
13 | | - # COMMAND ${CMAKE_COMMAND} -E copy_directory |
14 | | - # "${CMAKE_CURRENT_SOURCE_DIR}/" "${CMAKE_CURRENT_BINARY_DIR}/" |
15 | | - # ) |
16 | | - |
17 | | - #need this target to refresh our copy if anything in the source has changed |
18 | | - if( NOT ("${CMAKE_CURRENT_SOURCE_DIR}/" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/" ) ) |
19 | | - add_custom_target( hops4py_copy_src ALL |
20 | | - COMMAND cp -r "${CMAKE_CURRENT_SOURCE_DIR}/" "${CMAKE_CURRENT_BINARY_DIR}/" |
21 | | - ) |
22 | | - else() |
23 | | - add_custom_target( hops4py_copy_src) |
24 | | - endif() |
25 | | - |
26 | | - #setup-no-deps.py.in assumes that the system already has the python dependencies |
27 | | - #needed (numpy, matplotlib, future, scipy) and makes not attempt to manage or |
28 | | - #install them, this is also useful for off-line installations |
29 | | - set(SETUP_PY_IN "${CMAKE_CURRENT_BINARY_DIR}/setup-no-deps.py.in") |
30 | 3 | if(HOPS_PYPI_MANAGE_DEPS) |
31 | | - #if the user chooses, we can as pip to pull and install the python dependencies |
32 | | - #for us at time of installation (but don't do this automatically) |
33 | | - set(SETUP_PY_IN "${CMAKE_CURRENT_BINARY_DIR}/setup-deps.py.in") |
34 | | - endif(HOPS_PYPI_MANAGE_DEPS) |
35 | | - |
36 | | - set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") |
37 | | - configure_file(${SETUP_PY_IN} ${SETUP_PY}) |
38 | | - |
39 | | - #add a build target to catch problems before install (output not used) |
40 | | - if(HOPS3_PYTHON_EXTRAS) |
41 | | - add_custom_target(hops4py_build_target ALL |
42 | | - COMMAND ${PY_EXE} ${SETUP_PY} build |
43 | | - DEPENDS hops4py_copy_src |
44 | | - ) |
45 | | - endif(HOPS3_PYTHON_EXTRAS) |
| 4 | + |
| 5 | + #if the user chooses to enable HOPS_PYPI_MANAGE_DEPS, then we can use pip to pull/install the python dependencies |
| 6 | + #for us at time of installation, but we don't do this automatically |
| 7 | + set(REQUIREMENTS_TXT_IN "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt") |
| 8 | + set(REQUIREMENTS_TXT "${CMAKE_CURRENT_BINARY_DIR}/requirements.txt") |
| 9 | + configure_file(${REQUIREMENTS_TXT_IN} ${REQUIREMENTS_TXT}) |
| 10 | + install(CODE "execute_process(COMMAND ${PY_EXE} -m pip install --upgrade --target=${PYTHON_MODULE_INSTALL_DIR} -r ${REQUIREMENTS_TXT} )") |
| 11 | + |
| 12 | + else(HOPS_PYPI_MANAGE_DEPS) |
| 13 | + |
| 14 | + #look for our minimal set of python dependencies and warn user if they are not found |
| 15 | + set(PYTHON_PACKAGES "numpy" "scipy" "matplotlib") |
| 16 | + |
| 17 | + foreach(pkg IN LISTS PYTHON_PACKAGES) |
| 18 | + execute_process( |
| 19 | + COMMAND ${PY_EXE} -c "import ${pkg}" |
| 20 | + RESULT_VARIABLE _status |
| 21 | + OUTPUT_QUIET |
| 22 | + ERROR_QUIET |
| 23 | + ) |
| 24 | + if(NOT _status EQUAL 0) |
| 25 | + message(WARNING "Python package '${pkg}' not found. You may need to install it, or toggle HOPS_PYPI_MANAGE_DEPS to ON ") |
| 26 | + set(MISSING_PYTHON_PACKAGES TRUE) |
| 27 | + endif() |
| 28 | + endforeach() |
| 29 | + |
| 30 | + #tell user how to install the missing dependencies |
| 31 | + if(MISSING_PYTHON_PACKAGES) |
| 32 | + message(STATUS "Not all python dependencies were found, some python extension functionality may be missing.") |
| 33 | + message(STATUS "You can install the missing packages automatically by enabling HOPS_PYPI_MANAGE_DEPS or manually with:") |
| 34 | + message(STATUS " pip install -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt") |
| 35 | + endif() |
46 | 36 |
|
47 | | - if("${PYTHON_SETUP}" STREQUAL "setuptools") |
48 | | - #use pip/setuptools |
49 | | - install(CODE "execute_process(COMMAND ${PY_EXE} -m pip install ${CMAKE_CURRENT_BINARY_DIR} --upgrade --target=${PYTHON_MODULE_INSTALL_DIR} )") |
50 | | - else() |
51 | | - #use distutils |
52 | | - install(CODE "execute_process( COMMAND ${PY_EXE} ${SETUP_PY} install --prefix=${CMAKE_INSTALL_PREFIX} )") |
53 | | - endif() |
| 37 | + endif(HOPS_PYPI_MANAGE_DEPS) |
54 | 38 |
|
55 | 39 | if(HOPS3_PYTHON_EXTRAS AND NOT HOPS3_USE_CXX) |
56 | 40 | add_subdirectory(mk4_module) |
57 | 41 | add_subdirectory(vpal_module) |
58 | 42 | add_subdirectory(ffcontrol_module) |
59 | | - endif(HOPS3_PYTHON_EXTRAS AND NOT HOPS3_USE_CXX) |
| 43 | + endif() |
60 | 44 |
|
61 | 45 | if(HOPS_ENABLE_TEST) |
62 | 46 | enable_testing() |
63 | 47 | add_subdirectory(test) |
64 | 48 | endif(HOPS_ENABLE_TEST) |
65 | 49 |
|
| 50 | + add_subdirectory(hops_module) |
66 | 51 | add_subdirectory(scripts) |
67 | 52 | add_subdirectory(plugins) |
68 | 53 |
|
|
0 commit comments