Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

34 changes: 0 additions & 34 deletions .github/environment_ci.yml

This file was deleted.

89 changes: 89 additions & 0 deletions .github/make_ci_environ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import tomllib
from pathlib import Path
import yaml
import os

def parse_pyproject(path: str, optional_sections_to_skip=None):
with open(path, "rb") as f:
data = tomllib.load(f)

deps = set()

# project.dependencies (PEP 621)
for dep in data.get("project", {}).get("dependencies", []):
if "numpy" in dep:
# numpy is also listed in build requirements with a higher version number
# so we skip it here to avoid conflicts.
continue
deps.add(dep)

# optional dependencies (PEP 621)
if optional_sections_to_skip is None:
optional_sections_to_skip = []
for group, group_deps in data.get("project", {}).get("optional-dependencies", {}).items():
if group in optional_sections_to_skip:
print("Skipping optional dependency group:", group)
continue
deps.update(group_deps)

deps.discard("geoana[all]")
deps.discard("geoana[doc,all]")
deps.discard("geoana[plot,extras,jittable]")

if "matplotlib" in deps:
deps.remove("matplotlib")
deps.add("matplotlib-base")
return deps

def create_env_yaml(deps, name="env", python_version=None, free_threaded=False):
conda_pkgs = []
pip_pkgs = []

for dep in deps:
# crude split: try to detect conda vs pip-only packages
if any(dep.startswith(pip_only) for pip_only in ["git+", "http:", "https:", "file:"]):
pip_pkgs.append(dep)
else:
conda_pkgs.append(dep)

dependencies = conda_pkgs
if pip_pkgs:
dependencies.append({"pip": pip_pkgs})

if python_version:
if free_threaded:
dependencies.insert(0, f"python-freethreading={python_version}")
else:
dependencies.insert(0, f"python={python_version}")

return {
"name": name,
"channels": ["conda-forge"],
"dependencies": dependencies,
}

if __name__ == "__main__":
pyproject_path = Path("pyproject.toml")

py_vers = os.environ.get("PYTHON_VERSION", "3.11")
is_free_threaded = os.environ.get("FREE_THREADED", "false").lower() == "true"
no_doc = os.environ.get("NO_DOC_BUILD", "false").lower() == "true"
no_numba = os.environ.get("NO_NUMBA", "false").lower() == "true"
env_name = os.environ.get("ENV_NAME", "geoana_env")

skips = ["all"]
if no_numba or is_free_threaded:
skips.append("jittable")
if no_doc:
skips.append("doc")

deps = parse_pyproject(pyproject_path, optional_sections_to_skip=skips)
if is_free_threaded:
deps.discard("matplotlib-base")
env_data = create_env_yaml(deps, name=env_name, python_version=py_vers, free_threaded=is_free_threaded)

out_name = "environment_ci.yml"
with open(out_name, "w") as f:
yaml.safe_dump(env_data, f, sort_keys=False)

print("✅ Generated environment_ci.yml with", len(deps), "dependencies")
50 changes: 34 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: Release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Build Distribution artifacts

on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
# macos-15-intel is an Intel runner, macos-14 is Apple silicon
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-14]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
uses: pypa/cibuildwheel@v3.2.0

- uses: actions/upload-artifact@v4
with:
Expand All @@ -31,7 +31,9 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Build sdist
run: pipx run build --sdist
Expand All @@ -45,9 +47,9 @@ jobs:
# We can host it here on github though for those that need it (re: jupyter-light).
pure_python:
name: Create pure-python wheel
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Python
Expand All @@ -68,20 +70,35 @@ jobs:
distribute:
name: Distribute documentation
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.13"

- name: Create Conda environment file
run: |
python -m pip install pyyaml
python .github/make_ci_environ.py
env:
PYTHON_VERSION: "3.13"
ENV_NAME: geoana-test
NO_NUMBA: "true"

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
environment-file: .github/environment_ci.yml
activate-environment: geoana-test
python-version: "3.11"
activate-environment: geoana-test
- name: Install Our Package
run: |
pip install --no-build-isolation --editable . --config-settings=setup-args="-Dwith_extensions=true"
Expand All @@ -108,6 +125,7 @@ jobs:
pure_python
]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
defaults:
run:
shell: bash -l {0}
Expand Down
69 changes: 37 additions & 32 deletions .github/workflows/test_with_conda.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: Testing With Conda
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
build_and_test:
name: Testing (${{ matrix.python-version }}, ${{ matrix.os }})
name: Testing (${{ matrix.python-version }}${{ matrix.free-threaded && 't' || '' }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -18,39 +15,47 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.11", "3.12", "3.13", "3.14"]
free-threaded: [false, true]
include:
- free-threaded: true
no_doc: true
- python-version: "3.14"
no_numba: true
exclude:
- python-version: "3.11"
free-threaded: true
- python-version: "3.12"
free-threaded: true

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.13"

- name: Create Conda environment file
run: |
python -m pip install pyyaml
python .github/make_ci_environ.py
env:
PYTHON_VERSION: ${{ matrix.python-version}}
FREE_THREADED: ${{ matrix.free-threaded && 'true' || 'false' }}
NO_DOC_BUILD: ${{ matrix.no_doc && 'true' || 'false' }}
NO_NUMBA: ${{ matrix.no_numba && 'true' || 'false' }}
ENV_NAME: geoana-test


- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
environment-file: .github/environment_ci.yml
environment-file: environment_ci.yml
activate-environment: geoana-test
python-version: ${{ matrix.python-version }}

- name: Install numba
if: matrix.python-version != '3.13'
# Numba doesn't work on python 3.13 just yet:
run: |
conda install --yes -c conda-forge numba

# Install discretize from it's repo until wheels/conda-forge built against numpy2.0 available:
- name: Pull Discretize
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: 'simpeg/discretize'
ref: 'main'
path: 'discretize'

- name: Install discretize
run: |
pip install ./discretize

- name: Conda information
run: |
Expand All @@ -64,7 +69,7 @@ jobs:

- name: Run Tests
run: |
pytest tests --cov-config=.coveragerc --cov=geoana --cov-report=xml -s -v -W ignore::DeprecationWarning
pytest tests --cov-config=.coveragerc --cov=geoana --cov-report=xml -s -v -W ignore::DeprecationWarning ${{ matrix.NO_DOC_BUILD && ' -k "not docs"'|| ''}}

- name: "Upload coverage to Codecov"
if: matrix.python-version == '3.11'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ geoana/kernels/_extensions/potential_field_prism_api.h
geoana/version.py

.idea/

.vscode/

environment_ci.yml
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
'matplotlib': ('http://matplotlib.org/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
'matplotlib': ('https://matplotlib.org/stable/', None),
}


Expand Down
22 changes: 22 additions & 0 deletions geoana/kernels/_extensions/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
add_languages('c', 'cpp', 'cython')

py_dep = py.dependency()
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cy = meson.get_compiler('cython')

_global_c_args = cc.get_supported_arguments(
'-Wno-unused-but-set-variable',
'-Wno-unused-function',
'-Wno-conversion',
'-Wno-misleading-indentation',
)
add_project_arguments(_global_c_args, language : 'c')

# We need -lm for all C code (assuming it uses math functions, which is safe to
# assume for SciPy). For C++ it isn't needed, because libstdc++/libc++ is
# guaranteed to depend on it.
m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif

numpy_nodepr_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION']

Expand Down
3 changes: 3 additions & 0 deletions geoana/kernels/_extensions/potential_field_prism.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cython: freethreading_compatible = True
# cython: language_level=3
# cython: embedsignature=True
cimport cython

from libc.math cimport sqrt, log, atan
Expand Down
Loading
Loading