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 20, 2024
1 parent f445532 commit 9754a2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
from qstack import spahm
from qstack import mathutils
from qstack import orcaio
from qstack import qml
if 'b2r2' not in dir(qml):
del qml


# qstack.regression needs sklearn to work
try:
import sklearn
except ImportError:
Expand Down
16 changes: 16 additions & 0 deletions qstack/qml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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)
from qstack_qml import *
sys.path.pop(0)
del sys
else:
try:
from qstack_qml import *
except ImportError:
pass
del os, _qstack_qml_path

0 comments on commit 9754a2a

Please sign in to comment.