-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PYTHON_STRATEGY=PYTHONPATH, tidy before migration to SIRF
- Loading branch information
Showing
4 changed files
with
68 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Install python packages via pip and setup.py | ||
if(PYTHONINTERP_FOUND) | ||
set(PYTHON_SETUP_PKGS "sirf" CACHE INTERNAL "list of provided python packages") | ||
|
||
# alias sirf.p* -> p* for backward-compatibility | ||
function(python_pkg_alias PY_PKG_NEW PY_PKG_OLD) | ||
list(APPEND PYTHON_SETUP_PKGS ${PY_PKG_NEW}) | ||
set(PYTHON_SETUP_PKGS "${PYTHON_SETUP_PKGS}" PARENT_SCOPE) | ||
set(SETUP_PY_INIT_IN "${CMAKE_CURRENT_SOURCE_DIR}/cmake/__init__.py.in") | ||
set(SETUP_PY_INIT "${PYTHON_DEST}/${PY_PKG_NEW}/__init__.py") | ||
configure_file("${SETUP_PY_INIT_IN}" "${SETUP_PY_INIT}") | ||
# message(STATUS "setup.py:${SETUP_PY_INIT}") | ||
message(STATUS "setup.py:${PY_PKG_NEW}<-${PY_PKG_OLD}") | ||
endfunction(python_pkg_alias) | ||
python_pkg_alias(pGadgetron "sirf.pGadgetron") | ||
python_pkg_alias(pSTIR "sirf.pSTIR") | ||
python_pkg_alias(pUtilities "sirf.pUtilities") | ||
python_pkg_alias(pygadgetron "sirf.pygadgetron") | ||
python_pkg_alias(pystir "sirf.pystir") | ||
python_pkg_alias(pyiutilities "sirf.pyiutilities") | ||
# convert to python CSV tuple for setup.py configure_file | ||
string(REPLACE ";" "', '" PYTHON_SETUP_PKGS_CSV "${PYTHON_SETUP_PKGS}") | ||
set(PYTHON_SETUP_PKGS_CSV "'${PYTHON_SETUP_PKGS_CSV}'") | ||
# message(STATUS "setup.py:pacakges:${PYTHON_SETUP_PKGS_CSV}") | ||
|
||
# Create setup.py | ||
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/cmake/setup.py.in") | ||
set(SETUP_PY "${PYTHON_DEST}/setup.py") | ||
set(SETUP_PY_INIT "${PYTHON_DEST}/sirf/__init__.py") | ||
message(STATUS "setup.py:${SETUP_PY}") | ||
configure_file("${SETUP_PY_IN}" "${SETUP_PY}") | ||
|
||
# python setup.py build | ||
add_custom_command(OUTPUT "${SETUP_PY_INIT}" | ||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PYTHON_DEST}/sirf" | ||
COMMAND "${CMAKE_COMMAND}" -E touch "${SETUP_PY_INIT}" | ||
COMMAND "${PYTHON_EXECUTABLE}" setup.py build | ||
DEPENDS "${SETUP_PY_IN}" | ||
WORKING_DIRECTORY "${PYTHON_DEST}") | ||
|
||
add_custom_target(pybuild_sirf ALL DEPENDS ${SETUP_PY_INIT}) | ||
|
||
# python setup.py install | ||
if("${PYTHON_STRATEGY}" STREQUAL "SETUP_PY") | ||
install(CODE "execute_process(COMMAND\n\ | ||
\"${PYTHON_EXECUTABLE}\" setup.py install\n\ | ||
WORKING_DIRECTORY \"${PYTHON_DEST}\")") | ||
endif() | ||
endif(PYTHONINTERP_FOUND) |