Skip to content

Commit

Permalink
Merge branch 'develop' into command_line_instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
aburrell authored Dec 30, 2024
2 parents e2d6ece + f2ceb71 commit f8b7306
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9"]
python-version: ["3.11"]

env:
FC: gfortran
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
numpy_ver: ["latest"]
test_config: ["latest"]
include:
# Support different GA Mac environmnets
- python-version: "3.9"
os: "macos-13"
- python-version: "3.10"
os: "macos-13"
- python-version: "3.11"
os: "macos-latest"
- python-version: "3.12"
os: "macos-latest"
# NEP29 compliance settings
- python-version: "3.10"
numpy_ver: "1.25"
os: "ubuntu-latest"
test_config: "NEP29"

name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} with Numpy ${{ matrix.numpy_ver }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -44,23 +54,28 @@ jobs:
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
gfortran --version
pip install flake8 meson-python pytest pytest-cov pytest-xdist scipy
pip install "numpy>=1.19.5,<2"
pip install "numpy>=1.19.5"
- name: Install NEP29 dependencies
if: ${{ matrix.test_config == 'NEP29'}}
run: |
pip install numpy==${{ matrix.numpy_ver }}
- name: Install on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pip install .[test]
run: pip install --upgrade-strategy only-if-needed .[test]

- name: Install on MacOS-13
if: ${{ matrix.os == 'macos-13' }}
run: |
brew reinstall gcc@14
CC=/usr/local/bin/gcc-14 pip install .[test]
CC=/usr/local/bin/gcc-14 pip install --upgrade-strategy only-if-needed .[test]
- name: Install on MacOS-Latest
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew reinstall gcc@14
CC=/opt/homebrew/bin/gcc-14 pip install .[test]
CC=/opt/homebrew/bin/gcc-14 pip install --upgrade-strategy only-if-needed .[test]
- name: Install on Windows
if: ${{ matrix.os == 'windows-latest' }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Changelog
------------------
* Adapted codebase to read IRGF coefficients from a file (updated to IGRF-14)
* Updated docs to reflect missing command-line executable
* Updated package to be compliant and installable with numpy 2.0+
* Added tests for Python 3.12 and NEP29
* Fixed link to logo in the README

2.0.2 (2024-11-12)
------------------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ Badges
.. |doi| image:: https://www.zenodo.org/badge/doi/10.5281/zenodo.4585641.svg
:target: https://doi.org/10.5281/zenodo.1214206

.. |logo| image:: docs/apexpy.png
.. |logo| image:: https://github.com/aburrell/apexpy/blob/main/docs/apexpy.png
:alt: ApexPy logo: yellow magnetic field lines surrounding the Earth's surface, which is blue
5 changes: 3 additions & 2 deletions apexpy/apex.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Apex(object):
Notes
-----
The calculations use IGRF-13 with coefficients from 1900 to 2025 [1]_.
The calculations use IGRF-14 with coefficients from 1900 to 2030 [1]_.
The geodetic reference ellipsoid is WGS84.
Expand All @@ -87,7 +87,8 @@ def __init__(self, date=None, refh=0, datafile=None, fortranlib=None):
self.set_refh(refh) # Reference height in km

if date is None:
self.year = helpers.toYearFraction(dt.datetime.utcnow())
self.year = helpers.toYearFraction(dt.datetime.now(
tz=dt.timezone.utc))
else:
try:
# Convert date/datetime object to decimal year
Expand Down
2 changes: 1 addition & 1 deletion apexpy/tests/test_Apex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ def test_map_EV_to_height_array_location(self, ev_flag, test_mapped,
# Set the base input and output values
eshape = list(arr_shape)
eshape.insert(0, 3)
edata = np.array([[1, 2, 3]] * np.product(arr_shape)).transpose()
edata = np.array([[1, 2, 3]] * np.prod(arr_shape)).transpose()
in_args = [60, 15, 100, 500, edata.reshape(tuple(eshape))]

# Update inputs for one vectorized value if this is a location input
Expand Down
5 changes: 1 addition & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ Tested environments
The package has been tested with the following setups (others might work, too):

* Windows (64 bit Python), Linux (64 bit), and Mac (64 bit)
* Python 3.9, 3.10, 3.11

Note that :py:mod:`apexpy` is NOT currently compatable with Python 3.12 or
`NumPy 2.0 <https://numpy.org/doc/stable/numpy_2_0_migration_guide.html#numpy-2-migration-guide>`_.
* Python 3.9, 3.10, 3.11, and 3.12


Advanced Installation
Expand Down
43 changes: 31 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ add_languages('fortran', native: false)
fc = meson.get_compiler('fortran')
cc = meson.get_compiler('c')

# https://mesonbuild.com/Python-module.html
py_mod = import('python')
py3 = py_mod.find_installation()
py3_dep = py3.dependency()
message(py3.full_path())
message(py3.get_install_dir())

# Determine whether this is being compiled with numpy 1.X or 2.X
numpy_ver = run_command(py3,
['-c', 'import numpy; print(numpy.__version__.split(".")[0])'],
check : true
).stdout().strip()
is_numpytwo = numpy_ver.to_int() >= 2

message('The Numpy major version is: ', numpy_ver)


# Don't use the deprecated NumPy C API. Define this to a fixed version instead
# of NPY_API_VERSION in order not to break compilation for released versions
# when NumPy introduces a new deprecation. Use in a meson.build file::
Expand All @@ -28,7 +45,12 @@ cc = meson.get_compiler('c')
# 'source_fname',
# numpy_nodepr_api)
#
numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'
if is_numpytwo
numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_2_0_API_VERSION'
else
numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'
endif


# This argument is called -Wno-unused-but-set-variable by GCC, however Clang
# doesn't recognize that.
Expand All @@ -45,13 +67,6 @@ endif
# Add more link arguments
add_project_link_arguments('-lquadmath', language: ['c', 'fortran'])

# https://mesonbuild.com/Python-module.html
py_mod = import('python')
py3 = py_mod.find_installation()
py3_dep = py3.dependency()
message(py3.full_path())
message(py3.get_install_dir())

incdir_numpy = run_command(py3,
['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
check : true
Expand All @@ -64,15 +79,19 @@ incdir_f2py = run_command(py3,

inc_dirs = include_directories(incdir_numpy, incdir_f2py)

# Don't use the deprecated NumPy C API. Define this to a fixed version instead of
# NPY_API_VERSION in order not to break compilation for released SciPy versions
# when NumPy introduces a new deprecation. Use in a meson.build file::
# Don't use the deprecated NumPy C API. Define this to a fixed version instead
# of NPY_API_VERSION in order not to break compilation for released SciPy
# versions when NumPy introduces a new deprecation. Use in a meson.build file::
#
# py3.extension_module('_name',
# 'source_fname',
# numpy_nodepr_api)
#
c_flags = ['-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION']
if is_numpytwo
c_flags = ['-DNPY_NO_DEPRECATED_API=NPY_2_0_API_VERSION']
else
c_flags = ['-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION']
endif

# Platform detection to set more flags for Windows systems
is_windows = host_machine.system() == 'windows'
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ requires = [
"setuptools<60.0", # Do not increase, 60.0 enables vendored distutils
"Cython>=0.29.21",
"python-dev-tools",
"oldest-supported-numpy; python_version>'3.9'",
"numpy; python_version<='3.9'"
"numpy"
]

[project]
Expand All @@ -17,11 +16,11 @@ description = "A Python wrapper for Apex coordinates"
maintainers = [
{name = "Angeline Burrell", email = "[email protected]"},
]
requires-python = ">=3.9,<3.12"
requires-python = ">=3.9"
dependencies = [
# TODO: update to "pin-compatible" once possible, see
# https://github.com/FFY00/meson-python/issues/29
"numpy>=1.19.5,<2",
# https://github.com/mesonbuild/meson-python/issues/29
"numpy>=1.19.5",
]
readme = "README.rst"
keywords = [
Expand All @@ -46,6 +45,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries",
"Topic :: Scientific/Engineering :: Physics",
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Physics
Topic :: Utilities
Expand Down

0 comments on commit f8b7306

Please sign in to comment.