fix(python): expose carla.command namespace on ue5 module layout (#9634 PR #0u) - #9775
Merged
Blyron merged 4 commits intoJun 29, 2026
Merged
Conversation
The ue5-dev wheel installs `carla` as a single extension module (carla.cpython-*.so), not a package, so PythonAPI/carla/__init__.py is never executed at import time. Registering the command submodule as "carla.command" via PyImport_AddModule places it directly in sys.modules, which makes `from carla.command import ...` work without any __init__.py shim. Verified: from carla.command import SpawnActor, DestroyActor; carla.command.SpawnActor.__module__ == 'carla.command'. Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Python API’s command submodule registration so carla.command becomes the canonical import path (instead of libcarla.command), and documents the change in the changelog.
Changes:
- Register the Boost.Python
commandsubmodule undercarla.command. - Document the import-path fix in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| PythonAPI/carla/src/Commands.cpp | Changes the registered Python submodule name to carla.command. |
| CHANGELOG.md | Notes the Python import-path fix and rationale for UE5 wheels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 3, 2026
Contributor
Author
|
@LuisPovedaCano @Blyron Could you review this? |
Blyron
approved these changes
Jun 24, 2026
Contributor
|
Hello @youtalk, you have some conflicts here. This PR need to be rebased from upstream ue5-dev. |
Contributor
Author
|
@JArmandoAnaya I've merged the latest |
Contributor
Author
|
@Blyron Could you merge this? |
Contributor
|
once the pipeline passes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes
from carla.command import ...work on theue5-devPython API. This is the C++ binding half of issue #9634 PR #0u (the Python-agent half is #9774); the two are independent and targetue5-devdirectly.On
ue5-devthe installed wheel shipscarlaas a single bare extension module (carla.cpython-*.so), not a package — soPythonAPI/carla/__init__.pyis never executed at import time and asys.modulesshim placed there is dead code. The fix is a one-line change in the binding: registering the command submodule as"carla.command"viaPyImport_AddModuleplaces it directly insys.modules, which is exactly whatfrom carla.command import ...resolves against.scope().attr("command") = command_moduleis unchanged, socarla.command.Xattribute access keeps working, and the command classes now report__module__ == 'carla.command'.Ported from
ue4-devcommitaeeff9907(#8161), reworked for the ue5 module layout. Fixes #6414 onue5-dev.Part of #9634 (PR #0u).
Where has this been tested?
Rebuilt
carla-python-apiand reinstalled the wheel, then verified against a fresh interpreter (no manualsys.modulesinjection):from carla.command import SpawnActor, DestroyActorsucceeds.carla.command.SpawnActor.__module__ == 'carla.command';'carla.command' in sys.modulesisTrue.carla.command.FutureActor == 0(attribute access regression check passes).from carla.command import SpawnActor as S; S is carla.command.SpawnActor→True.Possible Drawbacks
__module__changes fromlibcarla.commandtocarla.command; this is the intended correction and matches how the module is imported.This change is