Skip to content

Commit

Permalink
Merge pull request #147 from neutrinoceros/bld/numpy_1.x_compat_shim
Browse files Browse the repository at this point in the history
BLD: reintroduce compatibility shim for compiling against numpy 1.x
  • Loading branch information
mhvk committed Apr 11, 2024
2 parents 6e92335 + 1ef2e23 commit 078ae11
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,35 @@ jobs:
python -m pip install --editable .[test]
(nm -u erfa/ufunc.*.so | grep eraA2af) || exit 1
(python -c 'import erfa' 2>&1 | grep -n 'too old') > /dev/null && (echo 'liberfa too old, skipping tests'; exit 0) || python -m pytest
build_against_numpy_1:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
# this is mainly meant to be useful on old or exotic archs
# so we use our oldest-supported Python
python-version: '3.9'
- name: Install build-time dependencies
run: |
python -m pip install --upgrade wheel setuptools setuptools_scm jinja2 'numpy<2.0'
- run: python -m pip list
- name: Build
# using --no-build-isolation allows us to skip pass build-system metadata
# from pyproject.toml
# In particular this allows us to use an older version of numpy than we
# normally require.
# building in --editable mode to avoid PYTHONPATH issues
run: |
python -m pip install --editable . --no-build-isolation
- name: Check
run: python -c "import erfa"
5 changes: 5 additions & 0 deletions erfa/ufunc.c.templ
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#include "erfa.h"
#include "erfaextra.h"

// Backported NumPy 2 API (can be removed if numpy 2 is required)
#if NPY_ABI_VERSION < 0x02000000
#define PyDataType_ELSIZE(descr) ((descr)->elsize)
#endif

// On gcc<10 we can run into the following:
//
// error: dereferencing pointer to incomplete type 'PyTypeObject'
Expand Down

0 comments on commit 078ae11

Please sign in to comment.