-
Notifications
You must be signed in to change notification settings - Fork 130
/
__init__.py
33 lines (24 loc) · 1.14 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
This is here so that the RETURNN repo root directory can be imported as a submodule.
This was used for the old flat code file structure, for usage like::
import returnn.TFUtil
We want to support the same code.
"""
from __future__ import annotations
import os
import sys
if globals().get("__package__", None) is None:
__package__ = __name__ # https://www.python.org/dev/peps/pep-0366/ # pylint: disable=redefined-builtin
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
if __name__ == "returnn":
# This is a bit tricky. `import returnn` in here will not work, as this is the reference to ourselves!
# Thus delete this ref, to enforce a reload of the right module.
# For the user, this will actually replace the `returnn` module by the right one.
# But this should be compatible.
sys.modules.pop("returnn", None)
# It is important that we have some `import returnn` below.
from returnn.__old_mod_loader__ import (
setup as _old_module_loader_setup,
) # nopep8 # pylint: disable=wrong-import-position
# noinspection PyUnboundLocalVariable
_old_module_loader_setup(package_name=__package__, modules=globals())