Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to fix ad_rss's import namespaces #8152

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

Daraan
Copy link
Contributor

@Daraan Daraan commented Sep 17, 2024

Description

Fixes #8093

This is a hack that fixes the messy import namespacing of the ad_rss library. Importing carla which in turns imports ad_rss as ad puts provides all its subpackages as top-level pckages/modules.

For example this is currently valid:

import carla
import ad
import core # ad.rss.core
import world ...

This raises an ImportError

import carla.ad

Also it creates ambigious import behavior where the order of imports matter, e.g. if I had a subpackage/module names like any of ad_rss subpackages the following code will also fail as it imports the wrong module

import carla  # assume with RSS
import world, core  # This imports ad subpackages instead of mine.

This is non-standard and confusing behavior.

See also: intel/ad-rss-lib#258


Note: This issue should actually be addressed by ad_rss lib or somewhere in the packaging process before creating the .so file

This PR manually adjust sys.modules["ad..."] to sys.modules["carla.ad..."] so that correct and normal import behavior is possible.


Where has this been tested?

  • Platform(s): Ubuntu 22.04
  • Python version(s): Python 3.10
  • Unreal Engine version(s): 4.26

Possible Drawbacks

  • Code that relies on the strange import behavior needs updates.
  • When the ad_rss requirement is updates the adjustments need to be checked again. I checked that it aligns with the currently latest master branch of https://github.com/intel/ad-rss-lib (4.5.3)
  • This is only a hack.

This change is Reviewable

@Daraan Daraan requested a review from a team as a code owner September 17, 2024 17:13
Copy link

update-docs bot commented Sep 17, 2024

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libcarla.py messy import of ad packages as top-level modules.
1 participant