You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jig_auto_package.cmake currently installs the per-package Python tree by hand:
_jig_create_top_level_python_package writes a generated __init__.py and uses raw install(FILES …) to drop it under ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}/.
_jig_generate_python_node does the same for each node's user .py files and the codegen output, again with raw install(FILES …).
ament_cmake_python only registers the pythonpath.sh / pythonpath.dsv environment hook from inside ament_python_install_package / ament_python_install_module. Neither of those is called by the auto-package flow, so the hook never gets registered.
This was invisible on jazzy/kilted because there PYTHON_INSTALL_DIR resolves to lib/python${PYV}/site-packages, which ament_export_pythonpath adds to PYTHONPATH by default. On humble, PYTHON_INSTALL_DIR resolves to local/lib/python3.10/dist-packages (Debian Python convention), which the default exported pythonpath hook does not cover — so source install/setup.bash left the package off PYTHONPATH and every launched Python node failed with ModuleNotFoundError: No module named '<pkg>'.
What we did as a stopgap
_jig_create_top_level_python_package now calls the private idempotent macro _ament_cmake_python_register_environment_hook() after the manual install. This is the same macro that ament_python_install_package uses internally, and its definition is identical across humble/jazzy/kilted in ament_cmake_python-extras.cmake. Verified: humble dagger run no longer reports No module named 'jig_example'.
That patch is tactical — it relies on a private ament macro and leaves the bespoke install flow in place.
What this ticket is for
Replace the manual install(FILES …) calls in _jig_create_top_level_python_package and _jig_generate_python_node with a single ament_python_install_package(\${PROJECT_NAME} PACKAGE_DIR <staging>) call.
Sketch
Stage the assembled package tree under \${CMAKE_CURRENT_BINARY_DIR}/python_staging/\${PROJECT_NAME}/:
top-level generated __init__.py
<node>/ subdir per Python node containing user .py files (symlinked from source via file(CREATE_LINK … SYMBOLIC) to preserve --symlink-install ergonomics) and the codegen output (interface.py, parameters.py, _parameters.py, generated __init__.py).
Redirect the per-node codegen add_custom_command outputs to write directly into the staging dir.
Wrap the staging steps in an add_custom_target(jig_python_staging ALL DEPENDS …).
Drop every Python install(FILES …) call from the two macros. Keep the wrapper-executable install (install(PROGRAMS … DESTINATION lib/\${PROJECT_NAME})) — that part is fine.
Call ament_python_install_package(\${PROJECT_NAME} PACKAGE_DIR \${staging}/\${PROJECT_NAME}) once from jig_auto_package, before ament_auto_package.
Remove the _ament_cmake_python_register_environment_hook() call added as the stopgap.
Why it's worth doing
Drops a dependency on a private _-prefixed ament macro (_ament_cmake_python_register_environment_hook). It's stable today but isn't API.
Aligns with the canonical ament path: setuptools-driven install, env hook auto-registered, future-distro-proof.
Reduces the surface area of bespoke CMake in the macro.
Sets us up to use SETUP_CFG / version metadata if we ever want to publish these as real wheels.
Background
jig_auto_package.cmakecurrently installs the per-package Python tree by hand:_jig_create_top_level_python_packagewrites a generated__init__.pyand uses rawinstall(FILES …)to drop it under${PYTHON_INSTALL_DIR}/${PROJECT_NAME}/._jig_generate_python_nodedoes the same for each node's user.pyfiles and the codegen output, again with rawinstall(FILES …).ament_cmake_pythononly registers thepythonpath.sh/pythonpath.dsvenvironment hook from insideament_python_install_package/ament_python_install_module. Neither of those is called by the auto-package flow, so the hook never gets registered.This was invisible on jazzy/kilted because there
PYTHON_INSTALL_DIRresolves tolib/python${PYV}/site-packages, whichament_export_pythonpathadds toPYTHONPATHby default. On humble,PYTHON_INSTALL_DIRresolves tolocal/lib/python3.10/dist-packages(Debian Python convention), which the default exported pythonpath hook does not cover — sosource install/setup.bashleft the package offPYTHONPATHand every launched Python node failed withModuleNotFoundError: No module named '<pkg>'.What we did as a stopgap
_jig_create_top_level_python_packagenow calls the private idempotent macro_ament_cmake_python_register_environment_hook()after the manual install. This is the same macro thatament_python_install_packageuses internally, and its definition is identical across humble/jazzy/kilted inament_cmake_python-extras.cmake. Verified: humble dagger run no longer reportsNo module named 'jig_example'.That patch is tactical — it relies on a private ament macro and leaves the bespoke install flow in place.
What this ticket is for
Replace the manual
install(FILES …)calls in_jig_create_top_level_python_packageand_jig_generate_python_nodewith a singleament_python_install_package(\${PROJECT_NAME} PACKAGE_DIR <staging>)call.Sketch
\${CMAKE_CURRENT_BINARY_DIR}/python_staging/\${PROJECT_NAME}/:__init__.py<node>/subdir per Python node containing user.pyfiles (symlinked from source viafile(CREATE_LINK … SYMBOLIC)to preserve--symlink-installergonomics) and the codegen output (interface.py,parameters.py,_parameters.py, generated__init__.py).add_custom_commandoutputs to write directly into the staging dir.add_custom_target(jig_python_staging ALL DEPENDS …).install(FILES …)call from the two macros. Keep the wrapper-executable install (install(PROGRAMS … DESTINATION lib/\${PROJECT_NAME})) — that part is fine.ament_python_install_package(\${PROJECT_NAME} PACKAGE_DIR \${staging}/\${PROJECT_NAME})once fromjig_auto_package, beforeament_auto_package._ament_cmake_python_register_environment_hook()call added as the stopgap.Why it's worth doing
_-prefixed ament macro (_ament_cmake_python_register_environment_hook). It's stable today but isn't API.SETUP_CFG/ version metadata if we ever want to publish these as real wheels.Acceptance criteria
dagger call build-and-test --src=. --ros-distro=humblepasses (modulo unrelated humble-rclpy compat issues being tracked separately).dagger call build-and-test --src=. --ros-distro=jazzyand…--ros-distro=kiltedstill pass.colcon build --symlink-installthen editing anodes/<node>/<node>.pyfile in the source tree takes effect on the next test run without a rebuild.share/<pkg>/environment/pythonpath.shis generated for any package usingjig_auto_packagewith Python nodes._ament_cmake_python_register_environment_hookcall and itsTODO(jig#NN)comment are removed.Pointers
jig/cmake/jig_auto_package.cmake(_jig_create_top_level_python_packagemacro).ament_cmake_python/cmake/ament_python_install_package.cmake(humble & jazzy share the structure).23-humble-support(issue humble support #23).