From c1a789e1944c32dabef1b3c761fa2d1123d3e712 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Fri, 12 May 2023 10:59:57 +0200
Subject: [PATCH] feat: SCHWED-5913 make invalid $OST_COMPOUNDS_CHEMLIB an
 error

---
 modules/base/pymod/__init__.py.in | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/base/pymod/__init__.py.in b/modules/base/pymod/__init__.py.in
index 2fabb1b7f..0dff2fd37 100644
--- a/modules/base/pymod/__init__.py.in
+++ b/modules/base/pymod/__init__.py.in
@@ -87,15 +87,14 @@ def _SetupCompoundsLib():
   """
   # Try with the $OST_COMPOUNDS_CHEMLIB environment variable
   compound_lib_path = os.getenv("OST_COMPOUNDS_CHEMLIB")
-  try:
-    _TrySetCompoundsLib(compound_lib_path)
-  except ValueError:
-    if compound_lib_path:
-      LogWarning("Could not load $OST_COMPOUNDS_CHEMLIB as a compound library"
-                 ": '%s'. Falling back to default." % ( compound_lib_path))
-    pass
-  else:
-    return
+  if compound_lib_path:
+    compound_lib = conop.CompoundLib.Load(compound_lib_path)
+    if compound_lib is None:
+      raise RuntimeError("Could not load $OST_COMPOUNDS_CHEMLIB as a compound "
+                         "library: '%s'." % compound_lib_path)
+    else:
+      conop.SetDefaultLib(compound_lib)
+      return
 
   # Try from GetSharedDataPath() - requires $OST_ROOT to be set.
   try:
-- 
GitLab