aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx
diff options
context:
space:
mode:
authorGravatar Michael Kieburtz <michaelkieburtz@gmail.com> 2021-08-20 10:08:07 -0700
committerGravatar GitHub <noreply@github.com> 2021-08-20 10:08:07 -0700
commitd53387b7688df37e2dac673d83d353b05c16fc44 (patch)
tree9bf2331042f9622e93f0cdd4c90d5e3cb677c321 /Python/pywarpx
parent881c4dfaed9d9e89b52621e6b4ad524f1c9d4105 (diff)
downloadWarpX-d53387b7688df37e2dac673d83d353b05c16fc44.tar.gz
WarpX-d53387b7688df37e2dac673d83d353b05c16fc44.tar.zst
WarpX-d53387b7688df37e2dac673d83d353b05c16fc44.zip
Improved error handling when the libwarpx shared object library can't be loaded (#2215)
* Improved error handling when the libwarpx shared library can't be loaded * Removed extra newline * Improved check and ended program on error
Diffstat (limited to 'Python/pywarpx')
-rwxr-xr-xPython/pywarpx/_libwarpx.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index a6b4cdc90..cd6875c1c 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -74,8 +74,13 @@ libname = "libwarpx.{0}.{1}".format(geometry_dim, mod_ext)
try:
libwarpx = ctypes.CDLL(os.path.join(_get_package_root(), libname))
-except OSError:
- raise Exception('"%s" was not installed. It can be installed by running "make" in the Python directory of WarpX' % libname)
+except OSError as e:
+ value = e.args[0]
+ if f'{libname}: cannot open shared object file: No such file or directory' in value:
+ raise Exception('"%s" was not installed. It can be installed by running "make" in the Python directory of WarpX' % libname) from e
+ else:
+ print("Failed to load the libwarpx shared object library")
+ raise
# WarpX can be compiled using either double or float
libwarpx.warpx_Real_size.restype = ctypes.c_int