Skip to content

Commit 03d96de

Browse files
committed
better warning when libOGDF.so is not found
1 parent 82ffe4e commit 03d96de

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/ogdf_python/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
import warnings
2+
import sys
33

44
import cppyy.ll
55
from cppyy import include as cppinclude, cppdef, cppexec, nullptr
@@ -16,17 +16,22 @@
1616
cppyy.add_include_path(os.path.join(BUILD_DIR, "include"))
1717
cppyy.add_include_path(os.path.join(BUILD_DIR, "..", "include"))
1818
cppyy.add_library_path(BUILD_DIR)
19-
else:
20-
warnings.warn("ogdf-python couldn't find OGDF. "
21-
"Please set environment variables OGDF_INSTALL_DIR or OGDF_BUILD_DIR.")
2219

2320
cppyy.cppdef("#undef NDEBUG")
24-
cppyy.include("ogdf/basic/internal/config_autogen.h")
25-
cppyy.include("ogdf/basic/internal/config.h")
26-
cppyy.include("ogdf/basic/Graph.h")
27-
cppyy.include("ogdf/fileformats/GraphIO.h")
21+
try:
22+
cppyy.include("ogdf/basic/internal/config_autogen.h")
23+
cppyy.include("ogdf/basic/internal/config.h")
24+
cppyy.include("ogdf/basic/Graph.h")
25+
cppyy.include("ogdf/fileformats/GraphIO.h")
2826

29-
cppyy.load_library("libOGDF.so")
27+
cppyy.load_library("libOGDF")
28+
except:
29+
print(
30+
"ogdf-python couldn't load OGDF. "
31+
"If you haven't installed OGDF globally to your system, "
32+
"please set environment variables OGDF_INSTALL_DIR or OGDF_BUILD_DIR.",
33+
file=sys.stderr)
34+
raise
3035

3136
import ogdf_python.doxygen
3237
import ogdf_python.pythonize

0 commit comments

Comments
 (0)