diff --git a/example_python/setup.py b/example_python/setup.py index c757ec8c..966c0f6e 100644 --- a/example_python/setup.py +++ b/example_python/setup.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import sys +import os from setuptools import setup @@ -8,12 +9,15 @@ if len(sys.argv) >= 2 and sys.argv[1] != 'clean': from generate_parameter_library_py.setup_helper import generate_parameter_module + current_dir = os.path.dirname(os.path.abspath(__file__)) + src_dir = os.path.abspath(os.path.join(current_dir, package_name)) + # set module_name and yaml file module_name = 'admittance_parameters' yaml_file = 'generate_parameter_module_example/parameters.yaml' validation_module = 'generate_parameter_module_example.custom_validation' generate_parameter_module( - module_name, yaml_file, validation_module=validation_module + module_name, yaml_file, validation_module=validation_module, src_dir=src_dir ) setup( diff --git a/example_python/test/test_parameters.py b/example_python/test/test_parameters.py new file mode 100644 index 00000000..08dc591c --- /dev/null +++ b/example_python/test/test_parameters.py @@ -0,0 +1,7 @@ +import generate_parameter_module_example +print("OK 1") +import generate_parameter_module_example.minimal_publisher +print("OK 2") +from generate_parameter_module_example.minimal_publisher import MinimalParam + +print(MinimalParam) \ No newline at end of file diff --git a/generate_parameter_library_py/generate_parameter_library_py/setup_helper.py b/generate_parameter_library_py/generate_parameter_library_py/setup_helper.py index ed4de8e3..d619c404 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/setup_helper.py +++ b/generate_parameter_library_py/generate_parameter_library_py/setup_helper.py @@ -32,7 +32,7 @@ from generate_parameter_library_py.generate_python_module import run -def generate_parameter_module(module_name, yaml_file, validation_module=''): +def generate_parameter_module(module_name, yaml_file, validation_module='', src_dir=None): # TODO there must be a better way to do this. I need to find the build directory so I can place the python # module there build_dir = None @@ -55,17 +55,18 @@ def generate_parameter_module(module_name, yaml_file, validation_module=''): install_dir = os.path.join( colcon_ws, 'install', - pkg_name, 'lib', py_version, 'site-packages', pkg_name, ) - build_dir = os.path.join(colcon_ws, 'build', pkg_name, pkg_name) + build_dir = os.path.join(colcon_ws, 'build', pkg_name, 'build', 'lib', pkg_name) break if build_dir: run(os.path.join(build_dir, module_name + '.py'), yaml_file, validation_module) + if src_dir: + run(os.path.join(src_dir, module_name + '.py'), yaml_file, validation_module) if install_dir: run( os.path.join(install_dir, module_name + '.py'), yaml_file, validation_module