Skip to content

Commit 143b50b

Browse files
committed
Merge branch 'master'
2 parents 068c349 + 0f22edb commit 143b50b

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

source/python_src/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ if(PY_EXE)
22

33
if(HOPS_PYPI_MANAGE_DEPS)
44

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} )")
5+
#look for our minimal set of python dependencies and install them if they are not found
6+
set(PYTHON_PACKAGES "numpy" "scipy" "matplotlib")
7+
8+
foreach(pkg IN LISTS PYTHON_PACKAGES)
9+
execute_process(
10+
COMMAND ${PY_EXE} -c "import ${pkg}"
11+
RESULT_VARIABLE _status
12+
OUTPUT_QUIET
13+
ERROR_QUIET
14+
)
15+
if(NOT _status EQUAL 0)
16+
message(WARNING "Python package '${pkg}' not found, installing it via pip. ")
17+
install(CODE "execute_process(COMMAND ${PY_EXE} -m pip install --upgrade --target=${PYTHON_MODULE_INSTALL_DIR} ${pkg} )")
18+
else()
19+
message(STATUS "Python package '${pkg}' found.")
20+
endif()
21+
endforeach()
1122

1223
else(HOPS_PYPI_MANAGE_DEPS)
1324

@@ -24,6 +35,8 @@ if(PY_EXE)
2435
if(NOT _status EQUAL 0)
2536
message(WARNING "Python package '${pkg}' not found. You may need to install it, or toggle HOPS_PYPI_MANAGE_DEPS to ON ")
2637
set(MISSING_PYTHON_PACKAGES TRUE)
38+
else()
39+
message(STATUS "Python package '${pkg}' found.")
2740
endif()
2841
endforeach()
2942

tag-rev.last

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5ee7cb
1+
bfd451

0 commit comments

Comments
 (0)