fix: sys path (#50)
* external_code * rm sys path --------- Co-authored-by: ljleb <set>pull/51/head
parent
a402ea8949
commit
8cb468e3a3
|
|
@ -1,12 +1,23 @@
|
|||
import contextlib
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def fix_path():
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
extension_path = str(Path(__file__).parent.parent.parent)
|
||||
added = False
|
||||
if extension_path not in sys.path:
|
||||
sys.path.append(extension_path)
|
||||
sys.path.insert(0, extension_path)
|
||||
added = True
|
||||
|
||||
yield
|
||||
|
||||
if added:
|
||||
sys.path.remove(extension_path)
|
||||
|
||||
|
||||
fix_path()
|
||||
del fix_path
|
||||
from .api import *
|
||||
with fix_path():
|
||||
del fix_path, contextlib
|
||||
from .api import *
|
||||
|
|
|
|||
Loading…
Reference in New Issue