Skip to content

Commit e11eb34

Browse files
authored
Fix Python install (#122)
1 parent 02e59c0 commit e11eb34

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int main(int argc, char * argv[])
107107
```python
108108
import rclpy
109109
from rclpy.node import Node
110-
from turtlesim_parameters import turtlesim_parameters
110+
from turtlesim_pkg.turtlesim_parameters import turtlesim_parameters
111111
112112
def main(args=None):
113113
rclpy.init(args=args)

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
```
1717
source install/setup.bash
18-
ros2 run generate_parameter_library_example test_node --ros-args --params-file --params-file src/generate_parameter_library/examples/cpp/config/implementation.yaml
18+
ros2 run generate_parameter_library_example test_node --ros-args --params-file src/generate_parameter_library/examples/cpp/config/implementation.yaml
1919
2020
```
2121
## Or run the Python node

examples/python/generate_parameter_module_example/minimal_publisher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import rclpy
3131
import rclpy.node
3232

33-
from admittance_parameters import admittance_controller
33+
from generate_parameter_module_example.admittance_parameters import (
34+
admittance_controller,
35+
)
3436

3537

3638
class MinimalParam(rclpy.node.Node):

generate_parameter_library_py/generate_parameter_library_py/setup_helper.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,37 @@ def generate_parameter_module(module_name, yaml_file, validation_module=""):
3636
# TODO there must be a better way to do this. I need to find the build directory so I can place the python
3737
# module there
3838
build_dir = None
39+
install_dir = None
3940
for i, arg in enumerate(sys.argv):
4041
# Look for the `--build-directory` option in the command line arguments
4142
if arg == "--build-directory" or arg == "--build-base":
42-
build_dir = sys.argv[i + 1]
43-
tmp = os.path.split(build_dir)
44-
build_dir = os.path.join(*tmp[:-1])
43+
build_arg = sys.argv[i + 1]
44+
45+
path_split = os.path.split(build_arg)
46+
path_split = os.path.split(path_split[0])
47+
pkg_name = path_split[1]
48+
path_split = os.path.split(path_split[0])
49+
colcon_ws = path_split[0]
50+
51+
tmp = sys.version.split()[0]
52+
tmp = tmp.split(".")
53+
py_version = f"python{tmp[0]}.{tmp[1]}"
54+
55+
install_dir = os.path.join(
56+
colcon_ws,
57+
"install",
58+
pkg_name,
59+
"lib",
60+
py_version,
61+
"site-packages",
62+
pkg_name,
63+
)
64+
build_dir = os.path.join(colcon_ws, "build", pkg_name, pkg_name)
4565
break
66+
4667
if build_dir:
4768
run(os.path.join(build_dir, module_name + ".py"), yaml_file, validation_module)
69+
if install_dir:
70+
run(
71+
os.path.join(install_dir, module_name + ".py"), yaml_file, validation_module
72+
)

0 commit comments

Comments
 (0)