@@ -2,28 +2,43 @@ module Core
22
33using PyCall
44
5+ # Global variables to store Python modules
56# Global variables to store Python modules
67const rclpy = PyNULL ()
78const rclpy_node = PyNULL ()
9+ const py_sys = PyNULL ()
810
911function __init__ ()
1012 if contains (lowercase (get (ENV , " GITHUB_WORKFLOW" , " " )), " automerge" )
1113 return
1214 end
13-
15+
1416 try
17+ copy! (py_sys, pyimport (" sys" ))
18+ if length (ARGS ) > 0
19+ py_sys. argv = ARGS
20+ end
21+
22+ if ! (dirname (@__FILE__ ) in py_sys." path" )
23+ pushfirst! (py_sys." path" , dirname (@__FILE__ ))
24+ end
25+
1526 if ! haskey (ENV , " AMENT_PREFIX_PATH" )
1627 @warn " ROS2 environment not sourced"
1728 return
1829 end
19-
20- # Import rclpy and node
21- py_sys = pyimport (" sys" )
22- ros_python_path = " /opt/ros/humble/lib/python3.10/site-packages"
2330
24- if ros_python_path not in py_sys." path"
25- pushfirst! (py_sys." path" , ros_python_path)
26- end
31+ # Get Python executable path
32+ python_path = PyCall. python
33+
34+ # Add ROS2 Python path
35+ ros_python_path = " /opt/ros/jazzy/lib/python3.12/site-packages"
36+ py """
37+ import sys
38+ ros_path = $ ros_python_path
39+ if ros_path not in sys.path:
40+ sys.path.insert(0 , ros_path)
41+ """
2742
2843 copy! (rclpy, pyimport (" rclpy" ))
2944 copy! (rclpy_node, pyimport (" rclpy.node" ))
0 commit comments