From 42e1ffa4510bceee2f6b6e6a6d88d8aabd2d8966 Mon Sep 17 00:00:00 2001 From: Daniel Czurko Date: Mon, 13 May 2024 16:46:27 +0200 Subject: [PATCH] fix: Implement review findings --- conanfile.py | 11 ++++++----- plugins/basic/CMakeLists.txt | 5 ++--- python/python_api/cloe/__init__.py | 2 +- python/python_api/cloe/_runner.py | 9 +++++---- python/python_api/cloe/src/CMakeLists.txt | 9 --------- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1e1327b9b..36bde8231 100644 --- a/conanfile.py +++ b/conanfile.py @@ -90,7 +90,7 @@ def requirements(self): self.requires("fmt/9.1.0") self.requires("inja/3.4.0") self.requires("nlohmann_json/3.11.2") - self.requires("incbin/cci.20211107"), + self.requires("incbin/cci.20211107"), self.requires("spdlog/1.11.0") self.requires("eigen/3.4.0") self.requires("cli11/2.3.2", private=True) @@ -133,7 +133,6 @@ def generate(self): tc.cache_variables["CLOE_ENGINE_WITH_SERVER"] = self.options.engine_server tc.cache_variables["CLOE_ENGINE_WITH_LRDB"] = self.options.engine_lrdb tc.cache_variables["CLOE_PYTHON_API"] = self.options.python_api - tc.cache_variables["PYTHON_BINDINGS_LOCAL_DEV"] = not self.in_local_cache tc.generate() def build(self): @@ -202,12 +201,14 @@ def package_info(self): pydir = os.path.join(self.build_folder, "lib/cloe/python") py_path = os.path.join(self.source_folder, "python/python_api") libdir = os.path.join(self.build_folder, "lib") + cloe_lib_path = libdir else: self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "cloe")) bindir = os.path.join(self.package_folder, "bin") luadir = os.path.join(self.package_folder, "lib/cloe/lua") pydir = os.path.join(self.package_folder, "lib/cloe/python") py_path = pydir + cloe_lib_path = os.path.join(self.package_folder, "lib/cloe/python/cloe") libdir = None self.output.info(f"Appending PATH environment variable: {bindir}") @@ -215,10 +216,10 @@ def package_info(self): self.output.info(f"Appending CLOE_LUA_PATH environment variable: {luadir}") self.runenv_info.prepend_path("CLOE_LUA_PATH", luadir) if libdir is not None: - #TODO self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}") self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) if self.options.python_api: - self.output.info(f"Appending PYHTONPATH and BASIC_CLOE_PYTHON_BINDINGS environment variables: {pydir}") + self.output.info(f"Appending PYHTONPATH and CLOE_PYTHON_BINDINGS environment variables: {pydir}") self.runenv_info.prepend_path("PYTHONPATH", str(py_path)) - self.runenv_info.prepend_path("BASIC_CLOE_PYTHON_BINDINGS", str(pydir)) + self.runenv_info.prepend_path("PYTHONPATH", str(cloe_lib_path)) + self.runenv_info.prepend_path("CLOE_PYTHON_BINDINGS", str(pydir)) diff --git a/plugins/basic/CMakeLists.txt b/plugins/basic/CMakeLists.txt index 7f88d4807..f0aa8bfcb 100644 --- a/plugins/basic/CMakeLists.txt +++ b/plugins/basic/CMakeLists.txt @@ -33,13 +33,12 @@ set_target_properties(_basic_bindings PROPERTIES CXX_STANDARD_REQUIRED ON ) -if(PYTHON_BINDINGS_LOCAL_DEV) - set_target_properties(_basic_bindings +set_target_properties(_basic_bindings PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloe/python" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloe/python" ) -endif() + install(TARGETS _basic_bindings LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cloe/python) diff --git a/python/python_api/cloe/__init__.py b/python/python_api/cloe/__init__.py index 9a971bd64..13c313524 100644 --- a/python/python_api/cloe/__init__.py +++ b/python/python_api/cloe/__init__.py @@ -1,2 +1,2 @@ from ._runner import TestRunner, Simulation -from ._cloe_bindings import CallbackResult +from _cloe_bindings import CallbackResult diff --git a/python/python_api/cloe/_runner.py b/python/python_api/cloe/_runner.py index dac5ab7c6..3200bef94 100644 --- a/python/python_api/cloe/_runner.py +++ b/python/python_api/cloe/_runner.py @@ -6,8 +6,8 @@ from typing import Optional, Dict, Any from queue import Queue, Empty -from ._cloe_bindings import SimulationDriver, CallbackResult, DataBrokerAdapter, SimulationDriver, Stack -from ._cloe_bindings import Simulation as _Simulation +from _cloe_bindings import SimulationDriver, CallbackResult, DataBrokerAdapter, SimulationDriver, Stack +from _cloe_bindings import Simulation as _Simulation @dataclass @@ -113,6 +113,7 @@ def run(): t = Thread(target=run) t.start() self.q.get(True) + #minimater error, no vehicle def __next__(self): return self @@ -208,11 +209,11 @@ def __init__(self, stack: Optional[Dict[str, Any]] = None): self._sim = _Simulation(full_config_stack, self.driver, uuid="123") - if "BASIC_CLOE_PYTHON_BINDINGS" in os.environ: + if "CLOE_PYTHON_BINDINGS" in os.environ: import importlib.util import sys binding_libs = [] - for binding_dir in os.environ["BASIC_CLOE_PYTHON_BINDINGS"].split(":"): + for binding_dir in os.environ["CLOE_PYTHON_BINDINGS"].split(":"): if len(str(binding_dir)) > 1: binding_path = Path(binding_dir) if binding_path.exists(): diff --git a/python/python_api/cloe/src/CMakeLists.txt b/python/python_api/cloe/src/CMakeLists.txt index ed2bf2ddf..929759d3d 100644 --- a/python/python_api/cloe/src/CMakeLists.txt +++ b/python/python_api/cloe/src/CMakeLists.txt @@ -1,5 +1,3 @@ -set(PYTHON_BINDINGS_LOCAL_DEV OFF CACHE BOOL "This sets the compiler output to the local source tree so - the cloe python project can be simply imported.") set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION}) if(CLOE_FIND_PACKAGES) @@ -24,13 +22,6 @@ set_target_properties(_cloe_bindings PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -if(PYTHON_BINDINGS_LOCAL_DEV) - set_target_properties(_cloe_bindings - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.." - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.." - ) -endif() target_link_libraries(_cloe_bindings PUBLIC cloe::stacklib cloe::databroker-bindings cloe::simulation) target_include_directories(_cloe_bindings PRIVATE ${PROJECT_SOURCE_DIR}/engine/src)