Skip to content

Commit

Permalink
More fallbacks and removed another unnecessary requirement.
Browse files Browse the repository at this point in the history
  • Loading branch information
max-krichenbauer committed Dec 9, 2019
1 parent 56cd765 commit 3576bf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 13 additions & 3 deletions ament_virtualenv/ament_virtualenv/glob_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,22 @@ def find_in_workspaces(project, file):
colcon_paths = os.environ.get('COLCON_PREFIX_PATH')
if not colcon_paths:
# can happen when install/setup.bash has not been sourced yet
# fall back to using the working directory
workspaces = [os.getcwd()]
# fall back to using AMENT_PREFIX_PATH (points at install/<package>)
ament_paths = os.environ.get('AMENT_PREFIX_PATH')
if not ament_paths:
# final fallback: use working directory (usually src/<package>)
workspaces = [os.getcwd()]
else:
ament_paths = ament_paths.split(os.pathsep)
for path in ament_paths:
if (os.path.sep + 'install' + os.path.sep) in path:
workspaces.append(os.path.join(path, '..'))
workspaces.append(os.path.join(path, '..', '..' , 'src'))
break
else:
colcon_paths = colcon_paths.split(os.pathsep)
for path in colcon_paths:
workspaces.append(os.path.join(path))
workspaces.append(path)
workspaces.append(os.path.join(path, '..' , 'src'))

for workspace in (workspaces or []):
Expand Down
1 change: 0 additions & 1 deletion test_ament_cmake_virtualenv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

find_package(ament_cmake_virtualenv REQUIRED)
ament_generate_virtualenv(PYTHON_VERSION 2)
Expand Down

0 comments on commit 3576bf1

Please sign in to comment.