Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge install for python packages #241

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

darrenjkt
Copy link

@darrenjkt darrenjkt commented Jan 29, 2025

Existing install of the parameter python script fails when using colcon build with --merge-install and/or --install-base /opt/someuser/ros_ws

This PR enables us to pass through a custom install base e.g. /opt/someuser/ros_ws as well as the merge-install flag for proper installation of python packages in the same way as colcon build.

One way to obtain the merge install path can be done as below and passed into generate_parameter_module.

if len(sys.argv) >= 2 and sys.argv[1] != 'clean':
    from generate_parameter_library_py.setup_helper import generate_parameter_module
    
    colcon_prefix_path = os.getenv("COLCON_PREFIX_PATH", None)
    if not colcon_prefix_path:
        raise ValueError(f"Unable to find merge install base")    
    base_dir = colcon_prefix_path.split(':')[0] 

    generate_parameter_module(
        module_name="detector_onnx_parameters", 
        yaml_file="detector_onnx/detector_onnx_parameters.yaml", 
        install_base=base_dir,
        merge_install=True
    )

With this PR, running the following below commands in /home/rosuser/ros_ws (and editing the args above respectively), will place the auto-gen parameter script in the following:

> colcon build
/home/rosuser/ros_ws/install/my_package/lib/python3.12/site-packages/my_package/my_package_parameters.py

> colcon build --install-base /opt/myuser/ros_ws
/opt/myuser/ros_ws/my_package/lib/python3.12/site-packages/my_package/my_package_parameters.py

> colcon build --merge-install 
/home/rosuser/ros_ws/install/lib/python3.12/site-packages/my_package/my_package_parameters.py

> colcon build --merge-install --install-base /opt/myuser/ros_ws 
/opt/myuser/ros_ws/lib/python3.12/site-packages/my_package/my_package_parameters.py

@darrenjkt darrenjkt marked this pull request as draft January 29, 2025 04:22
@darrenjkt darrenjkt marked this pull request as ready for review January 29, 2025 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant