diff options
author | 2020-12-04 01:17:52 -0800 | |
---|---|---|
committer | 2020-12-04 01:17:52 -0800 | |
commit | 1f8ab0e625f27e9201b0da9dcfbab52c30112089 (patch) | |
tree | d103b48a9177358a7bcea1473b34c39aa09e9ce0 /Python/pywarpx/_libwarpx.py | |
parent | 65091cca136b896cb4d538a3533e33fc25569bfe (diff) | |
download | WarpX-1f8ab0e625f27e9201b0da9dcfbab52c30112089.tar.gz WarpX-1f8ab0e625f27e9201b0da9dcfbab52c30112089.tar.zst WarpX-1f8ab0e625f27e9201b0da9dcfbab52c30112089.zip |
CMake: objects, shared library, Python (#1519)
* CMake: libwarpx
Reorder CMake builds to collect everything in an object
file library, which is then used to link out a shared library
and the WarpX executable app.
* setup.py: Install up to 3 libs at once
Inside CMake build dir:
```
PYWARPX_LIB_DIR=$PWD/lib python3 -m pip wheel ../Python/
```
* Docs: CMake + Python
* CI: Python CMake Package
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index 2560da235..f8f57bd85 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -59,10 +59,18 @@ else: _libc = ctypes.CDLL(_find_library('c')) +# macOS/Linux use .so, Windows uses .pyd +# https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll +if os.name == 'nt': + mod_ext = "pyd" +else: + mod_ext = "so" +libname = "libwarpx{0}.{1}".format(geometry_dim, mod_ext) + try: - libwarpx = ctypes.CDLL(os.path.join(_get_package_root(), "libwarpx%s.so"%geometry_dim)) + libwarpx = ctypes.CDLL(os.path.join(_get_package_root(), libname)) except OSError: - raise Exception('libwarpx%s.so was not installed. It can be installed by running "make" in the Python directory of WarpX'%geometry_dim) + raise Exception('"%s" was not installed. It can be installed by running "make" in the Python directory of WarpX' % libname) # WarpX can be compiled using either double or float libwarpx.warpx_Real_size.restype = ctypes.c_int |