Skip to content

Commit

Permalink
fix: install generated parameter module into source directory
Browse files Browse the repository at this point in the history
  • Loading branch information
imcelroy committed Jan 10, 2025
1 parent 1449658 commit b1a3abd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion example_python/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import sys
import os

from setuptools import setup

Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,11 +60,13 @@ def generate_parameter_module(module_name, yaml_file, validation_module=''):
'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
Expand Down

0 comments on commit b1a3abd

Please # to comment.