Skip to content

Commit

Permalink
Merge pull request #69 from jcapriot/pyproject
Browse files Browse the repository at this point in the history
Pyproject.toml
  • Loading branch information
jcapriot committed Oct 31, 2023
2 parents 0d2a7da + 5fe9513 commit 74f5ddd
Show file tree
Hide file tree
Showing 26 changed files with 417 additions and 224 deletions.
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.git_archival.txt export-subst
# Excluding files from an sdist generated by meson-python

.github/* export-ignore
docs/* export-ignore
examples/* export-ignore
tests/* export-ignore

.coveragerc export-ignore
.flake8 export-ignore
.git* export-ignore
*.yml export-ignore
*.yaml export-ignore
27 changes: 18 additions & 9 deletions .github/workflows/test_with_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -35,11 +35,14 @@ jobs:
libdlf
cython
setuptools_scm
meson-python>=0.14.0
meson
ninja
build
discretize
matplotlib
jupyter
utm
numba
pytest
pytest-cov
sphinx
Expand All @@ -49,16 +52,20 @@ jobs:
graphviz
pillow
cache-environment: true
- name: Install numba
if: matrix.python-version != '3.12'
# Numba doesn't work on python 3.12 just yet, so conditionally install it into the environment:
run: |
micromamba install numba
- name: Install Our Package
run: |
export BUILD_GEOANA_EXT=1
pip install -e .
pip install --no-build-isolation --editable . --config-settings=setup-args="-Dwith_extensions=true"
conda list
- name: Run Tests
run: |
pytest --cov-config=.coveragerc --cov=geoana --cov-report=xml -s -v -W ignore::DeprecationWarning
- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version }} == '3.10'
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -84,6 +91,10 @@ jobs:
libdlf
cython
setuptools_scm
meson-python>=0.14.0
meson
ninja
build
discretize
matplotlib
jupyter
Expand All @@ -100,8 +111,7 @@ jobs:
cache-environment: true
- name: Prepare source distribution
run: |
export BUILD_GEOANA_EXT=1
python setup.py sdist
python -m build --no-isolation --skip-dependency-check --sdist . --config-settings=setup-args="-Dwith_extensions=true"
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand All @@ -110,8 +120,7 @@ jobs:
skip_existing: true
- name: Install package
run: |
export BUILD_GEOANA_EXT=1
pip install -e .
pip install --no-build-isolation --editable . --config-settings=setup-args="-Dwith_extensions=true"
- name: Build documentation
run: |
cd docs
Expand Down
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

10 changes: 6 additions & 4 deletions geoana/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

__author__ = 'SimPEG developers'
__license__ = 'MIT'
__copyright__ = 'Copyright 2017 SimPEG developers'
__copyright__ = 'Copyright 2023 SimPEG developers'

from importlib.metadata import version, PackageNotFoundError

# Version
try:
# - Released versions just tags: 0.8.0
# - GitHub commits add .dev#+hash: 0.8.1.dev4+g2785721
# - Uncommitted changes add timestamp: 0.8.1.dev4+g2785721.d20191022
from geoana.version import version as __version__
except ImportError:
__version__ = version("geoana")
except PackageNotFoundError:
# If it was not installed, then we don't know the version. We could throw a
# warning here, but this case *should* be rare. discretize should be
# warning here, but this case *should* be rare. geoana should be
# installed properly!
from datetime import datetime

Expand Down
10 changes: 10 additions & 0 deletions geoana/earthquake/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

python_sources = [
'__init__.py',
'oksar.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/earthquake'
)
14 changes: 14 additions & 0 deletions geoana/em/fdem/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

python_sources = [
'__init__.py',
'base.py',
'halfspace.py',
'layered.py',
'simple_functions.py',
'wholespace.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/em/fdem'
)
14 changes: 14 additions & 0 deletions geoana/em/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

python_sources = [
'__init__.py',
'base.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/em'
)

subdir('fdem')
subdir('static')
subdir('tdem')
10 changes: 0 additions & 10 deletions geoana/em/setup.py

This file was deleted.

13 changes: 13 additions & 0 deletions geoana/em/static/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

python_sources = [
'__init__.py',
'freespace.py',
'halfspace.py',
'sphere.py',
'wholespace.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/em/static'
)
13 changes: 13 additions & 0 deletions geoana/em/tdem/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

python_sources = [
'__init__.py',
'base.py',
'halfspace.py',
'simple_functions.py',
'wholespace.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/em/tdem'
)
84 changes: 84 additions & 0 deletions geoana/kernels/_extensions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# NumPy include directory
# The try-except is needed because when things are
# split across drives on Windows, there is no relative path and an exception
# gets raised. There may be other such cases, so add a catch-all and switch to
# an absolute path. Relative paths are needed when for example a virtualenv is
# placed inside the source tree; Meson rejects absolute paths to places inside
# the source tree.
# For cross-compilation it is often not possible to run the Python interpreter
# in order to retrieve numpy's include directory. It can be specified in the
# cross file instead:
# [properties]
# numpy-include-dir = /abspath/to/host-pythons/site-packages/numpy/core/include
#
# This uses the path as is, and avoids running the interpreter.
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
if incdir_numpy == 'not-given'
incdir_numpy = run_command(py,
[
'-c',
'''import os
import numpy as np
try:
incdir = os.path.relpath(np.get_include())
except Exception:
incdir = np.get_include()
print(incdir)
'''
],
check: true
).stdout().strip()
else
_incdir_numpy_abs = incdir_numpy
endif
inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)

# Deal with M_PI & friends; add `use_math_defines` to c_args or cpp_args
# Cython doesn't always get this right itself (see, e.g., gh-16800), so
# explicitly add the define as a compiler flag for Cython-generated code.
is_windows = host_machine.system() == 'windows'
if is_windows
use_math_defines = ['-D_USE_MATH_DEFINES']
else
use_math_defines = []
endif

numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'
c_undefined_ok = ['-Wno-maybe-uninitialized']

cython_c_args = [numpy_nodepr_api, use_math_defines]

cython_cpp_args = cython_c_args

module_path = 'geoana/kernels/_extensions'

py.extension_module(
'potential_field_prism',
'potential_field_prism.pyx',
include_directories: incdir_numpy,
c_args: cython_c_args,
install: true,
subdir: module_path,
dependencies : [py_dep, np_dep],
)

py.extension_module(
'rTE',
['rTE.pyx', '_rTE.cpp'],
include_directories: incdir_numpy,
cpp_args: cython_cpp_args,
install: true,
subdir: module_path,
dependencies : [py_dep, np_dep],
override_options : ['cython_language=cpp'],
)

python_sources = [
'__init__.py',
]

py.install_sources(
python_sources,
subdir: module_path
)
31 changes: 0 additions & 31 deletions geoana/kernels/_extensions/setup.py

This file was deleted.

16 changes: 16 additions & 0 deletions geoana/kernels/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

python_sources = [
'__init__.py',
'potential_field_prism.py',
'tranverse_electric_reflections.py',
]

py.install_sources(
python_sources,
subdir: 'geoana/kernels'
)

with_extensions = get_option('with_extensions')
if with_extensions
subdir('_extensions')
endif
11 changes: 0 additions & 11 deletions geoana/kernels/setup.py

This file was deleted.

18 changes: 18 additions & 0 deletions geoana/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

python_sources = [
'__init__.py',
'gravity.py',
'plotting_utils.py',
'shapes.py',
'spatial.py',
'utils.py',
]

py.install_sources(
python_sources,
subdir: 'geoana'
)

subdir('earthquake')
subdir('em')
subdir('kernels')
10 changes: 0 additions & 10 deletions geoana/setup.py

This file was deleted.

Loading

0 comments on commit 74f5ddd

Please sign in to comment.