Skip to content

Commit

Permalink
packaging: add help importing qstack_qml in __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-o-marsh committed Jun 19, 2024
1 parent f445532 commit 3b7b008
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions qstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,29 @@
from qstack import mathutils
from qstack import orcaio

# qstack.regression needs sklearn to work
try:
import sklearn
except ImportError:
pass
else:
from qstack import regression
del sklearn

# qstack.qml is in a different python package
# but prefer "the local version of it" if we are in a development environment, and both sources are there.
import os
_qstack_qml_path = os.path.join(os.path.dirname(__file__), 'qstack-qml')
if os.path.isfile(os.path.join(_qstack_qml_path, 'qstack_qml', '__init__.py')):
import sys
sys.path.insert(0,_qstack_qml_path)
import qstack_qml as qml
sys.path.pop(0)
del sys
else:
try:
import qstack_qml as qml
except ImportError:
pass
del os, _qstack_qml_path

0 comments on commit 3b7b008

Please sign in to comment.