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 48a72d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions PythonAPI/carla/source/carla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def get_submodules(mod, parent):
# this should be fine for the current rss versions.
# NOTE: Check when updating RSS version
if v.__name__ != "map":
print(v, "already imported. This might create a carla.ad import hierarchy")
print(v, "already imported. This might create a wrong carla.ad import hierarchy")
continue
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 48a72d1

Please sign in to comment.