carla icon indicating copy to clipboard operation
carla copied to clipboard

Hack to fix ad_rss's import namespaces

Open Daraan opened this issue 1 year ago • 1 comments

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: https://github.com/intel/ad-rss-lib/issues/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 avatar Sep 17 '24 17:09 Daraan

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.

update-docs[bot] avatar Sep 17 '24 17:09 update-docs[bot]

Thanks for the PR. Could you please modify the PR to the ue4-dev branch rather than the dev branch? We are no longer maintaining that one.

PabloVD avatar Jan 15 '25 11:01 PabloVD

Thanks for PR, merged.

PabloVD avatar Jan 20 '25 12:01 PabloVD