forked from pyros-dev/catkin_pip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add catkin-pip-package-virtualenv.cmake
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 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
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,68 @@ | ||
if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 ) | ||
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" ) | ||
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 ) | ||
|
||
# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard | ||
if(catkin_pip_target_virtualenv_included) | ||
return() | ||
endif(catkin_pip_target_virtualenv_included) | ||
set(catkin_pip_target_virtualenv_included true) | ||
|
||
message(STATUS "Loading catkin-pip-package-virtualenv.cmake from ${CMAKE_CURRENT_LIST_DIR}... ") | ||
|
||
|
||
# catkin_pip_package override catkin_pip_package, otherwise CATKIN_PIP_ENV directory | ||
## ned to call `catkin_pip_requirements` after `catkin_pip_package_virtualenv` | ||
macro(catkin_pip_package_virtualenv package_name) | ||
if (NOT ${package_name} STREQUAL ${PROJECT_NAME}) | ||
message(FATAL_ERROR "We assume package_name(${package_name}) is equal to PROJECT_NAME(${PROJECT_NAME})") | ||
endif() | ||
|
||
unset(CATKIN_VIRTUALENV CACHE) | ||
find_program(CATKIN_VIRTUALENV NAMES virtualenv) | ||
|
||
# catkin_pip_package call catkin_package() to set CATKIN_PACKAGE_SHARE_DESTINATION | ||
catkin_pip_package(${package_name} ${ARGN}) | ||
|
||
if (CATKIN_VIRTUALENV) | ||
#set(CATKIN_VIRTUALENV "${CATKIN_VIRTUALENV} -q") # we can add all default basic options here. | ||
else () | ||
message(FATAL_ERROR "Could not find virtualenv") | ||
endif() | ||
|
||
# runnig the virtualenv command (configure time) | ||
set(CATKIN_VIRTUALENV_PATH_${package_name} ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/catkin_pip_env CACHE PATH "The virtual eivironment for each package") | ||
catkin_pip_runcmd(${CATKIN_VIRTUALENV} --system-site-packages ${CATKIN_VIRTUALENV_PATH_${package_name}}) | ||
|
||
### HACK somehow virtualenv create local dir | ||
catkin_pip_runcmd(cmake -E remove_directory ${CATKIN_VIRTUALENV_PATH_${package_name}}/local) | ||
|
||
# Setting up our environment (for devel space only) | ||
# Needed in case user call this directly (configure time) | ||
## NOTE This will set CATKIN_PIP within virtualenv | ||
catkin_pip_setup_prefix(${CATKIN_VIRTUALENV_PATH_${PROJECT_NAME}}) | ||
|
||
### OVERRIDE CATKIN_PIP_INSTALL_DEVEL_OUTPUTS is defined in catkin_pip_install_devel_target and used within catkin_pip_package | ||
catkin_pip_runcmd(${CATKIN_PIP} install -e ${CMAKE_CURRENT_SOURCE_DIR} --prefix "${CATKIN_VIRTUALENV_PATH_${package_name}}") | ||
|
||
endmacro() | ||
|
||
# Override catkin_pip_requirements to install using virtualenv pip | ||
function(catkin_pip_requirements requirements_txt) | ||
# Setting up our environment (for devel space only) | ||
# Needed in case user call this directly (configure time) | ||
if (CATKIN_VIRTUALENV) | ||
catkin_pip_setup_prefix(${CATKIN_VIRTUALENV_PATH_${PROJECT_NAME}}) | ||
else() | ||
catkin_pip_setup_prefix(${CATKIN_PIP_ENV}) | ||
endif() | ||
|
||
# runnig the pip command (configure time) | ||
if (CATKIN_VIRTUALENV) ## USE VIRTUALENV | ||
catkin_pip_runcmd(${CATKIN_PIP} install ${ARGN} -r ${requirements_txt} --ignore-installed --src ${CMAKE_SOURCE_DIR} --exists-action b) | ||
else() | ||
catkin_pip_runcmd(${CATKIN_PIP} install ${ARGN} -r ${requirements_txt} --ignore-installed --src ${CMAKE_SOURCE_DIR} --exists-action b --prefix "${CATKIN_DEVEL_PREFIX}") | ||
endif() | ||
|
||
endfunction() | ||
|
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
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