Skip to content

Commit

Permalink
Change install instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
leonfoks committed Oct 11, 2024
1 parent edc894f commit 3c7156a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 60 deletions.
13 changes: 3 additions & 10 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@
The Python (>=v3.5) interface consists of a C/C++ shared library (.so on Linux or .dll on Windows) called gatdaem1d which contains time-domain forward modelling and derivative functions which are called by the Python interpreter.

## Compiling and installing the C/C++ shared libraries
First the shared library needs to be built with CMake. See one of the CMake build scripts in the root directory of the ga-aem source code repository. If you are only interested in the Python interface, you need only build the ***`python_bindings`*** target.

## Install directory contents
After being built successfully the install directory should contain,
- [ga-aem-install-dir]/python contains the package set up or installation function `setup.py`.
- [ga-aem-install-dir]/python/gatdaem1d contains the file `__init__.py` which is the package's Python classes and function code. It is also where the compiled shared library will reside after compilation.
- On Linux the shared library is [ga-aem-install-dir]/python/gatdaem1d/gatdaem1d.so.
- On Windows the shared library is [ga-aem-install-dir]/python/gatdaem1d/gatdaem1d.dll.
- [ga-aem-install-dir]/python/examples contains example Python usage code.
We are using Meson to automatically build the required C++ library.
Ensure that the GNU C++ compiler is available, and FFTW has been installed.

## PIP install of the Python package
- To install as a python package you can then,
```bash
cd [ga-aem-install-dir]/python
python -m pip install .
pip install .
```
- Note that **`python`** may need to be **`python3`** on your system.

Expand Down
9 changes: 3 additions & 6 deletions python/gatdaem1d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@

#Function to load the shared library
def load_library():
import platform;
if(platform.system() == "Windows"):
ext = '.dll'
else:
ext = '.so'
libname = os.path.join(os.path.dirname(os.path.realpath(__file__)),"gatdaem1d"+ext)
files = os.listdir(os.path.dirname(os.path.realpath(__file__)))
libname = [file for file in files if 'gatdaem1d_ext' in file][0]
libname = os.path.join(os.path.dirname(os.path.realpath(__file__)),libname)
lib = ctypes.CDLL(libname)
return lib;

Expand Down
29 changes: 29 additions & 0 deletions python/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project('startingmeson', 'cpp',
version: '0.1'
)

py = import('python').find_installation(pure: false)

cpp = meson.get_compiler('cpp')

incdir = include_directories(['../src', '../submodules/cpp-utils/include'])

fftw = dependency('fftw3')

module_path = 'gatdaem1d'

shared_library('gatdaem1d_ext',
['../src/gatdaem1d.cpp', '../src/gatdaem1d.h'],
include_directories: incdir,
dependencies: fftw,
install: true)

python_sources = [
'gatdaem1d/__init__.py',
]

py.install_sources(
python_sources,
subdir: module_path
)

26 changes: 26 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
requires = ["meson-python"]
build-backend = "mesonpy"

[project]
name = "gatdaem1d"
version = "2.0.1"
description = "Time-domain airborne electromagnetic forward modelling"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
authors = [{ name = "Ross C Brodie", email = "[email protected]" }]
keywords = ["electromagnetic", "geophysics"]
dependencies = ["numpy"]
classifiers = [
'License :: OSI Approved',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Electromagnetic :: Airborne :: Forward modelling :: Geophysics'
]

[tool.spin]
package = 'gatdaem1d'

[tool.setuptools.packages.find]
gatdaem1d = ["."]
44 changes: 0 additions & 44 deletions python/setup.py

This file was deleted.

0 comments on commit 3c7156a

Please sign in to comment.