Skip to content

Commit

Permalink
Directly name "ad" as carla.libcarla.ad during build
Browse files Browse the repository at this point in the history
  • Loading branch information
Daraan committed Sep 23, 2024
1 parent 785adda commit a6c9c34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions PythonAPI/carla/source/carla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def get_submodules(mod, parent):
correct_path = parent+"."+v.__name__
ad_submodules[v] = correct_path
get_submodules(v, correct_path)
get_submodules(ad, "carla.ad") # type: ignore
if ad is sys.modules["ad"]: # type: ignore
sys.modules["carla.ad"] = sys.modules.pop("ad")
get_submodules(ad, "carla.libcarla.ad") # type: ignore
if ad.__name__ != "carla.libcarla.ad" and "ad" in sys.modules and ad is sys.modules["ad"] and "carla.libcarla.ad" not in sys.modules: # type: ignore
sys.modules["carla.libcarla.ad"] = sys.modules.pop("ad")
for mod, correct_name in ad_submodules.items():
# NOTE: Check when updating RSS version
#print("Correcting", mod.__name__, "to", correct_name)
Expand All @@ -59,6 +59,5 @@ def get_submodules(mod, parent):
__fix_ad_namespaces()
except Exception as e:
print("Could not clean ad_rss namespace due to", e, "Please report this bug")
pass

del __fix_ad_namespaces
2 changes: 1 addition & 1 deletion PythonAPI/carla/source/libcarla/AdRss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void export_ad() {
using namespace boost::python;

// create/import the ad module scope
object ad_module(handle<>(borrowed(PyImport_AddModule("ad"))));
object ad_module(handle<>(borrowed(PyImport_AddModule("carla.libcarla.ad"))));
scope().attr("ad") = ad_module;
scope submodule_scope = ad_module;
scope().attr("__doc__") = "Python binding of ad namespace C++ code";
Expand Down

0 comments on commit a6c9c34

Please sign in to comment.