feat: Virtual env site-packages auto add to sys.path
This commit is contained in:
@@ -25,14 +25,13 @@ extern "C" SQRESULT SQRAT_API sqmodule_load(HSQUIRRELVM vm, HSQAPI api)
|
|||||||
import importlib
|
import importlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
site.addsitedir('.')
|
site.addsitedir('.')
|
||||||
|
import os
|
||||||
|
|
||||||
spec = importlib.util.find_spec("g2o")
|
if 'VIRTUAL_ENV' in os.environ:
|
||||||
if spec is not None:
|
packages_path = os.path.join(os.environ['VIRTUAL_ENV'], 'Lib', 'site-packages')
|
||||||
if spec.submodule_search_locations:
|
sys.path.append(packages_path)
|
||||||
sys.path.append(spec.submodule_search_locations[0])
|
|
||||||
|
|
||||||
entry_point = 'pyg2o_entry'
|
entry_point = 'pyg2o_entry'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open('pyg2o.json', 'r') as f:
|
with open('pyg2o.json', 'r') as f:
|
||||||
json = json.loads(f.read())
|
json = json.loads(f.read())
|
||||||
@@ -47,6 +46,12 @@ extern "C" SQRESULT SQRAT_API sqmodule_load(HSQUIRRELVM vm, HSQAPI api)
|
|||||||
sys.path.append(spec.submodule_search_locations[0])
|
sys.path.append(spec.submodule_search_locations[0])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
spec = importlib.util.find_spec('g2o')
|
||||||
|
if spec is not None:
|
||||||
|
if spec.submodule_search_locations:
|
||||||
|
sys.path.append(spec.submodule_search_locations[0])
|
||||||
|
|
||||||
)", py::globals(), locals);
|
)", py::globals(), locals);
|
||||||
|
|
||||||
registerSquirrelConstants();
|
registerSquirrelConstants();
|
||||||
|
|||||||
Reference in New Issue
Block a user