Skip to content

Commit 9754a2a

Browse files
committedJun 20, 2024
packaging: add help importing qstack_qml in __init__
1 parent f445532 commit 9754a2a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎qstack/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
from qstack import spahm
99
from qstack import mathutils
1010
from qstack import orcaio
11+
from qstack import qml
12+
if 'b2r2' not in dir(qml):
13+
del qml
1114

15+
16+
# qstack.regression needs sklearn to work
1217
try:
1318
import sklearn
1419
except ImportError:

‎qstack/qml.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# qstack.qml is in a different python package
2+
# but prefer "the local version of it" if we are in a development environment, and both sources are there.
3+
import os
4+
_qstack_qml_path = os.path.join(os.path.dirname(__file__), 'qstack-qml')
5+
if os.path.isfile(os.path.join(_qstack_qml_path, 'qstack_qml', '__init__.py')):
6+
import sys
7+
sys.path.insert(0,_qstack_qml_path)
8+
from qstack_qml import *
9+
sys.path.pop(0)
10+
del sys
11+
else:
12+
try:
13+
from qstack_qml import *
14+
except ImportError:
15+
pass
16+
del os, _qstack_qml_path

0 commit comments

Comments
 (0)
Failed to load comments.