Skip to content

Commit bb362b0

Browse files
Merge pull request #8 from Michi-Tsubaki/tsubaki/fic-for-ci
Tsubaki/fic for ci
2 parents 5fcc0db + 0c10fcc commit bb362b0

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

src/core.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,43 @@ module Core
22

33
using PyCall
44

5+
# Global variables to store Python modules
56
# Global variables to store Python modules
67
const rclpy = PyNULL()
78
const rclpy_node = PyNULL()
9+
const py_sys = PyNULL()
810

911
function __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"))

test/runtests.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ using Test
22
using ROS2
33

44
@testset "ROS2.jl" begin
5-
if !haskey(ENV, "CI")
6-
include("aqua_test.jl")
7-
include("package.jl")
8-
include("example_test.jl")
9-
else
10-
@test true # CIではダミーテストのみ実行
11-
end
12-
end
5+
if !haskey(ENV, "CI")
6+
include("aqua_test.jl")
7+
include("package.jl")
8+
include("example_test.jl")
9+
else
10+
@test true # CIではダミーテストのみ実行
11+
end
12+
end
13+

0 commit comments

Comments
 (0)