I'm not sure how to describe this, but is there a way to create an façade package that handles multiple versions of a internal package?
Consider:
Foo/
__init__.py
A/
Bar/
__init__.py
etc.
B/
Bar/
__init__.py
etc.
C/
Bar/
__init__.py
etc.
Inside Package's __init__.py I have python logic to append the sys.path to point to one of the Bar packages depending on the runtime configuration. This leaves me using two python import statements.
import Foo
import Bar
Can I reduce that to one import statement and treat Foo as a façade for the correct version of Bar. The only was I have found is based on this post. In foo.py's __init__.py:
for attr in dir(bar):
globals()[attr] = getattr(bar, attr)