Skip to content

Commit 1812627

Browse files
authored
Fix building from package directory (#10)
If building from a directory that doesn't contain "src" ament_virtualenv would fail to find any packages in the local workspace.
1 parent 0ed56d3 commit 1812627

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ament_virtualenv/ament_virtualenv/glob_requirements.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ def find_in_workspaces(project, file, workspaces=[]):
8686
workspaces.append(path)
8787
workspaces.append(os.path.join(path, '..', 'src'))
8888
if len(workspaces) == 0:
89-
# final (local) fallback: use working directory (usually src/<package>)
90-
path = os.getcwd()
91-
if (os.path.sep + 'src') in path:
92-
workspaces.append(path)
89+
# If $CWD/src exists, append that
90+
path = Path(os.getcwd()) / "src"
91+
if path.exists():
92+
workspaces.append(str(path))
93+
94+
# Also append the current directory, in case we're building from the
95+
# package directory itself
96+
workspace.append(os.getcwd())
9397

9498
# Above, all paths required an "install/" or "src/" folder in order to qualify
9599
# as a workspace. This only applies to local workspaces but does not take into

0 commit comments

Comments
 (0)