From 6dd0225dda5b20d2bf5381c25b1455ea24466fa4 Mon Sep 17 00:00:00 2001 From: Daniel Stonier Date: Mon, 8 Apr 2013 23:10:37 +0900 Subject: [PATCH] Help find catkin python for install underlays This is a follow on from #397 --- cmake/templates/generate_cached_setup.py.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/templates/generate_cached_setup.py.in b/cmake/templates/generate_cached_setup.py.in index bf9c37085..c2848e04c 100644 --- a/cmake/templates/generate_cached_setup.py.in +++ b/cmake/templates/generate_cached_setup.py.in @@ -4,10 +4,19 @@ import os import stat import sys -# find the import relatively if available to work before installing catkin or overlaying installed version +# find the import for catkin's python package - either from source space or from an installed underlay if os.path.exists(os.path.join('@catkin_EXTRAS_DIR@', 'catkinConfig.cmake.in')): sys.path.insert(0, os.path.join('@catkin_EXTRAS_DIR@', '..', 'python')) -from catkin.environment_cache import generate_environment_script +try: + from catkin.environment_cache import generate_environment_script +except ImportError: + # search for catkin package in all workspaces and prepend to path + for workspace in "@CATKIN_WORKSPACES@".split(';'): + python_path = os.path.join(workspace, '@CATKIN_GLOBAL_PYTHON_DESTINATION@') + if os.path.isdir(os.path.join(python_path, 'catkin')): + sys.path.insert(0, python_path) + break + from catkin.environment_cache import generate_environment_script code = generate_environment_script('@CATKIN_DEVEL_PREFIX@/env.@script_ext@')