From 3b7b0084df4d43fa11023f67fa925ad470f252b0 Mon Sep 17 00:00:00 2001 From: Liam Marsh Date: Wed, 19 Jun 2024 18:08:14 +0200 Subject: [PATCH] packaging: add help importing qstack_qml in __init__ --- qstack/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qstack/__init__.py b/qstack/__init__.py index 71bb664..71127b6 100644 --- a/qstack/__init__.py +++ b/qstack/__init__.py @@ -9,6 +9,7 @@ from qstack import mathutils from qstack import orcaio +# qstack.regression needs sklearn to work try: import sklearn except ImportError: @@ -16,3 +17,21 @@ 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 + \ No newline at end of file