aboutsummaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/pywarpx/__init__.py10
-rwxr-xr-xPython/pywarpx/_libwarpx.py5
2 files changed, 13 insertions, 2 deletions
diff --git a/Python/pywarpx/__init__.py b/Python/pywarpx/__init__.py
index f0f4177d4..8b57f60fb 100644
--- a/Python/pywarpx/__init__.py
+++ b/Python/pywarpx/__init__.py
@@ -40,10 +40,16 @@ from .WarpX import warpx
from ._libwarpx import libwarpx
# This is a circular import and must happen after the import of libwarpx
-from . import picmi # isort:skip
+from . import picmi # isort:skip
+
+# intentionally query the value - only set once sim dimension is known
+def __getattr__(name):
+ # https://stackoverflow.com/a/57263518/2719194
+ if name == '__version__':
+ return libwarpx.__version__
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
# TODO
-#__version__ = cxx.__version__
#__doc__ = cxx.__doc__
#__license__ = cxx.__license__
#__author__ = cxx.__author__
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 592459132..615d9fd66 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -33,6 +33,9 @@ class LibWarpX():
self.initialized = False
atexit.register(self.finalize)
+ # set once libwarpx_so is loaded
+ self.__version__ = None
+
def __getattr__(self, attribute):
if attribute == 'libwarpx_so':
# If the 'libwarpx_so' is referenced, load it.
@@ -109,6 +112,8 @@ class LibWarpX():
except ImportError:
raise Exception(f"Dimensionality '{self.geometry_dim}' was not compiled in this Python install. Please recompile with -DWarpX_DIMS={_dims}")
+ self.__version__ = self.libwarpx_so.__version__
+
def getNProcs(self):
'''