astropy / astropy-healpix

BSD-licensed HEALPix for Astropy - maintained by @astrofrog and @lpsinger
https://astropy-healpix.readthedocs.io
BSD 3-Clause "New" or "Revised" License
53 stars 22 forks source link

astropy-healpix wheels can't be used with numpy-dev #202

Closed astrofrog closed 12 months ago

astrofrog commented 12 months ago

To reproduce the issue:

#!/bin/bash -xe

rm -rf testenv
python -m venv testenv
source testenv/bin/activate
pip install --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy --pre
pip install --extra-index-url https://pypi.anaconda.org/liberfa/simple pyerfa --pre
pip install --extra-index-url https://pypi.anaconda.org/astropy/simple astropy --pre
pip install astropy-healpix
pip freeze
python -c 'import astropy_healpix'

Result:

+ pip freeze
astropy==6.1.dev98+gaa0b136c4d
astropy-healpix==1.0.0
astropy-iers-data==0.2023.11.27.0.30.38
numpy==2.0.0.dev0
packaging==23.2
pyerfa==2.0.1.2.dev9+g0d5ddca
PyYAML==6.0.1
+ python -c 'import astropy_healpix'

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0.dev0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled against NumPy 2.0.

If you are a user of the module, the easiest solution will be to
either downgrade NumPy or update the failing module (if available).

NOTE: When testing against pre-release versions of NumPy 2.0
or building nightly wheels for it, it is necessary to ensure
the NumPy pre-release is used at build time.
The main way to ensure this is using no build isolation
and installing dependencies manually with NumPy.
For cibuildwheel for example, this may be achieved by using
the flag to pip:
    CIBW_BUILD_FRONTEND: pip; args: --no-build-isolation
installing NumPy with:
    pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
in the `CIBW_BEFORE_BUILD` step.  Please compare with the
solutions e.g. in astropy or matplotlib for how to make this
conditional for nightly wheel builds using expressions.
If you do not worry about using pre-releases of all
dependencies, you can also use `--pre --extra-index-url` in the
build frontend (instead of build isolation).
This will become unnecessary as soon as NumPy 2.0 is released.

If your dependencies have the issue, check whether they
have nightly wheels build against NumPy 2.0.

pybind11 note: You may see this message if using pybind11,
this is not problematic at pre-release time
it indicates the need for a new pybind11 release.

RuntimeError: module compiled against ABI version 0x1000009 but this version of numpy is 0x2000000
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tom/tmp/testenv/lib/python3.11/site-packages/astropy_healpix/__init__.py", line 13, in <module>
    from .high_level import *  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tom/tmp/testenv/lib/python3.11/site-packages/astropy_healpix/high_level.py", line 8, in <module>
    from .core import (nside_to_pixel_area, nside_to_pixel_resolution,
  File "/home/tom/tmp/testenv/lib/python3.11/site-packages/astropy_healpix/core.py", line 9, in <module>
    from . import _core
ImportError: numpy.core.multiarray failed to import

This is expected, but makes it difficult for downstream packages like reproject which need astropy-healpix as a dependency and want to test against numpy dev.

I'll set up some nightly wheels for astropy-healpix since there's no harm in doing that and will solve this issue.

astrofrog commented 12 months ago

We now have developer wheels on anaconda (same URL as astropy) so the following works:

#!/bin/bash -xe

rm -rf testenv
python -m venv testenv
source testenv/bin/activate
pip install --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy --pre
pip install --extra-index-url https://pypi.anaconda.org/liberfa/simple pyerfa --pre
pip install --extra-index-url https://pypi.anaconda.org/astropy/simple astropy astropy-healpix --pre
pip freeze
python -c 'import astropy_healpix'