diff --git a/.github/environment_ci.yml b/.github/environment_ci.yml new file mode 100644 index 00000000..9e03b20d --- /dev/null +++ b/.github/environment_ci.yml @@ -0,0 +1,34 @@ +name: geoana-test +channels: + - conda-forge +dependencies: + - numpy>=1.22.4 + - scipy>=1.8 + - libdlf + + # optionals + - matplotlib + - utm + + # documentation + - sphinx + - pydata-sphinx-theme==0.15.4 + - sphinx-gallery>=0.1.13 + - numpydoc>=1.5 + - discretize + - jupyter + - graphviz + - pillow + + # testing + - pytest + - pytest-cov + + # Building + - pip + - meson-python>=0.15.0 + - meson + - ninja + - cython>=3.0.8 + - setuptools_scm + - python-build \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 225621fe..73ffc426 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,76 +6,25 @@ on: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 jobs: - build_manylinux_x86_64_wheels: - name: Build manylinux_x86_64 - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 - env: - CIBW_BUILD: "*manylinux_x86_64" - CIBW_ARCHS_LINUX: x86_64 - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - build_manylinux_aarch64_wheels: - name: Build manylinux_aarch64 - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 - env: - CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "*manylinux_aarch64" - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl + 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] - build_musllinux_x86_64_wheels: - name: Build musllinux_x86_64 wheels - runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 - env: - CIBW_BUILD: "*musllinux_x86_64" - CIBW_ARCHS_LINUX: x86_64 - - uses: actions/upload-artifact@v3 with: - path: ./wheelhouse/*.whl + fetch-depth: 0 - build_mac_wheels: - name: Build macos wheels - runs-on: macos-11 - steps: - - uses: actions/checkout@v4 - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 - env: - CIBW_ARCHS_MACOS: x86_64 arm64 - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl + uses: pypa/cibuildwheel@v2.21.3 - build_windows_wheels: - name: Build Windows wheels - runs-on: windows-2019 - steps: - - uses: actions/checkout@v4 - - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 - env: - CIBW_ARCHS_WINDOWS: AMD64 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl # Don't upload this one to pypi, otherwise it will be preferred over every compiled one @@ -85,6 +34,8 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 with: @@ -95,7 +46,7 @@ jobs: python -m build find ./dist/*.whl | xargs pip install python -c "import geoana; geoana.show_config()" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./dist/geoana*.whl @@ -106,36 +57,16 @@ jobs: run: shell: bash -l {0} steps: - - uses: actions/checkout@v2 - - name: Setup environment - uses: mamba-org/setup-micromamba@v1 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v3 with: - environment-name: geoana-test - create-args: >- - python=3.11 - numpy>=1.20 - scipy>=1.8 - libdlf - cython - setuptools_scm - meson-python>=0.14.0 - meson - ninja - build - discretize - numba - matplotlib - jupyter - utm - pytest - pytest-cov - sphinx - sphinx-gallery>=0.1.13 - pydata-sphinx-theme=0.13.3 - numpydoc>=1.5 - graphviz - pillow - cache-environment: true + auto-update-conda: true + environment-file: .github/environment_ci.yml + activate-environment: geoana-test + python-version: "3.11" - name: Prepare source distribution run: | python -m build --no-isolation --skip-dependency-check --sdist . @@ -166,11 +97,7 @@ jobs: release: name: Create Release needs: [ - build_manylinux_x86_64_wheels, - build_manylinux_aarch64_wheels, - build_musllinux_x86_64_wheels, - build_mac_wheels, - build_windows_wheels, + build_wheels, pure_python ] runs-on: ubuntu-latest @@ -178,7 +105,7 @@ jobs: run: shell: bash -l {0} steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 name: Retrieve assets with: name: artifact diff --git a/.github/workflows/test_with_conda.yml b/.github/workflows/test_with_conda.yml index 56b9ae65..3de54d21 100644 --- a/.github/workflows/test_with_conda.yml +++ b/.github/workflows/test_with_conda.yml @@ -18,50 +18,33 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 - - name: Setup environment - uses: mamba-org/setup-micromamba@v1 + - uses: actions/checkout@v4 + + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v3 with: - environment-name: geoana-test - create-args: >- - python=${{ matrix.python-version }} - numpy>=1.20 - scipy>=1.8 - libdlf - cython - setuptools_scm - meson-python>=0.14.0 - meson - ninja - build - discretize - matplotlib - jupyter - utm - pytest - pytest-cov - sphinx - sphinx-gallery>=0.1.13 - pydata-sphinx-theme=0.13.3 - numpydoc>=1.5 - 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: + auto-update-conda: true + environment-file: .github/environment_ci.yml + activate-environment: geoana-test + python-version: ${{ matrix.python-version }} + + - name: Conda information run: | - micromamba install numba + conda info + conda list + conda config --show + - name: Install Our Package run: | - pip install --no-build-isolation --editable . --config-settings=setup-args="-Dwith_extensions=true" - conda list + pip install . --config-settings=setup-args="-Dwith_extensions=true" + - 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.11' uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 0ed7dd09..1c44a0ee 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,5 @@ geoana/kernels/_extensions/potential_field_prism_api.h # setuptools_scm geoana/version.py + +.idea/ diff --git a/geoana/kernels/_extensions/meson.build b/geoana/kernels/_extensions/meson.build index ac2c4d0c..a11f4474 100644 --- a/geoana/kernels/_extensions/meson.build +++ b/geoana/kernels/_extensions/meson.build @@ -1,38 +1,7 @@ + # 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) +np_dep = dependency('numpy') +numpy_nodepr_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'] # 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 @@ -44,7 +13,6 @@ 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] @@ -56,7 +24,6 @@ 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, @@ -66,7 +33,6 @@ py.extension_module( py.extension_module( 'rTE', ['rTE.pyx', '_rTE.cpp'], - include_directories: incdir_numpy, cpp_args: cython_cpp_args, install: true, subdir: module_path, diff --git a/pyproject.toml b/pyproject.toml index fb119ce1..fd878079 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,13 +2,10 @@ [build-system] build-backend = 'mesonpy' requires = [ - "meson-python>=0.14.0", - "Cython>=0.29.35", # when updating version, also update check in meson.build + "meson-python>=0.15.0", + "Cython>=3.0.8", "setuptools_scm[toml]>=6.2", - - # This package automatically provides all of the numpy pinning for different python - # versions and runtime requirements. - "oldest-supported-numpy", + "numpy>=2.0.0rc1", ] [project] @@ -16,7 +13,7 @@ name = 'geoana' dynamic = ["version"] description = 'Analytic expressions for geophysical responses' readme = 'README.rst' -requires-python = '>=3.8' +requires-python = '>=3.10' authors = [ {name = 'SimPEG developers', email = 'lindseyheagy@gmail.com'}, ] @@ -28,8 +25,6 @@ keywords = [ # release branches, see: # https://scipy.github.io/devdocs/dev/core-dev/index.html#version-ranges-for-numpy-and-other-dependencies dependencies = [ - # TODO: update to "pin-compatible" once possible, see - # https://github.com/mesonbuild/meson-python/issues/29 "numpy>=1.22.4", "scipy>=1.8", "libdlf", @@ -61,8 +56,8 @@ jittable = ["numba"] all = ["geoana[plot,extras,jittable]"] doc = [ "sphinx!=4.1.0", - "pydata-sphinx-theme==0.9.0", - "sphinx-gallery==0.1.13", + "pydata-sphinx-theme==0.15.4", + "sphinx-gallery>=0.1.13", "numpydoc>=1.5", "discretize", "jupyter", @@ -95,7 +90,7 @@ Repository = 'https://github.com/simpeg/geoana.git' # skip building wheels for python 3.6, 3.7, all pypy versions, and specialty linux # processors (still does arm builds though). # skip windows 32bit -skip = "cp36-* cp37-* pp* *_ppc64le *_i686 *_s390x *-win32 cp38-musllinux_* *-musllinux_aarch64" +skip = "cp36-* cp37-* cp38-* cp39-* pp* *_ppc64le *_i686 *_s390x *-win32 cp38-musllinux_* *-musllinux_aarch64" build-verbosity = "3" # test importing geoana to make sure externals are loadable.