fix: sys path (#50)

* external_code

* rm sys path

---------

Co-authored-by: ljleb <set>
pull/51/head
ljleb 2023-09-26 20:17:25 -04:00 committed by GitHub
parent a402ea8949
commit 8cb468e3a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -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 *