Skip to content

Commit ee5555f

Browse files
authored
fix: add setup helper fix (#6)
1 parent 0edb5d0 commit ee5555f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

generate_parameter_library_py/generate_parameter_library_py/setup_helper.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,27 @@ def generate_parameter_module(
3737
module_name, yaml_file, validation_module='', install_base=None, merge_install=False
3838
):
3939
# There's no nice way of auto-detecting if colcon was run with --merge-install or not
40-
# Have to manually specify for this function
40+
# Have to manually specify if using merge install
41+
42+
if len(sys.argv) <= 2:
43+
return
4144

4245
# Get python version
4346
tmp = sys.version.split()[0]
4447
tmp = tmp.split('.')
4548
py_version = f'python{tmp[0]}.{tmp[1]}'
4649

4750
# Get pkg name and colcon_ws
51+
colcon_ws, pkg_name = None, None
52+
for i, arg in enumerate(sys.argv):
53+
if arg == '--build-directory' or arg == '--build-base':
54+
build_arg = Path(sys.argv[i + 1])
55+
colcon_ws = build_arg.parent.parent.parent
56+
pkg_name = build_arg.parent.stem
57+
4858
cwd = Path(os.getcwd())
49-
colcon_ws = str(cwd.parent.parent)
50-
pkg_name = cwd.stem
59+
colcon_ws = colcon_ws if colcon_ws else str(cwd.parent.parent)
60+
pkg_name = pkg_name if pkg_name else cwd.stem
5161

5262
# Get paths
5363
if not install_base:

0 commit comments

Comments
 (0)