Skip to content

Build nightly wheels against developer version of Numpy#15524

Merged
astrofrog merged 3 commits intoastropy:mainfrom
astrofrog:cibuildwheel-dev-numpy
Oct 24, 2023
Merged

Build nightly wheels against developer version of Numpy#15524
astrofrog merged 3 commits intoastropy:mainfrom
astrofrog:cibuildwheel-dev-numpy

Conversation

@astrofrog
Copy link
Copy Markdown
Member

@astrofrog astrofrog commented Oct 24, 2023

This disables build isolation for nightly wheels in favor of installing dependencies by hand, and installs the latest developer version of numpy and the latest stable version of other build-time dependencies before doing the build. This also switches the regular builds from using pip wheel to python -m build by selecting the build framework (this is going to change by default in future, just anticipating the change).

I tested that the 'nightly' version works properly in my fork, e.g.:

https://github.com/astrofrog/astropy/actions/runs/6627003294/job/18001058641

Note the following in the cibuildwheel output:

before_build: pip install --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple setuptools setuptools_scm cython numpy>=0.0.dev0 extension-helpers
build_frontend: 
  name: pip
  args: ['--no-build-isolation']

Once we merge this PR we can use the workflow dispatch to force a new nightly build to make sure it also works properly.

From the logs, it looks like this is working but what I can't tell is if there is a way to find out for a given wheel what version of Numpy it was built against, to double check.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

… build-time dependencies to build nightly wheels
@astrofrog astrofrog added Release no-changelog-entry-needed Build all wheels Run all the wheel builds rather than just a selection labels Oct 24, 2023
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@astrofrog
Copy link
Copy Markdown
Member Author

Ok this seems to work fine in main, so if people are happy with it I suggest we merge and then trigger a build with the workflow dispatch.

@pllim pllim added this to the v6.0 milestone Oct 24, 2023
@pllim
Copy link
Copy Markdown
Member

pllim commented Oct 24, 2023

From the logs, it looks like this is working but what I can't tell is if there is a way to find out for a given wheel what version of Numpy it was built against, to double check.

Can @seberg advise here? 🙏

Copy link
Copy Markdown
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only do this for scheduled or dispatched events? Shouldn't we be consistent? That is, if I apply "build all wheels" label on a PR, I would expect the same thing to happen, except no wheel upload.

Also I think this only solves half our problem. We also need pyerfa dev that is built against numpy-dev, no? xref liberfa/pyerfa#109

Comment thread .github/workflows/publish.yml
@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Oct 24, 2023

I think we'd still want to check that the wheels we build work with stable numpy, no? If we did that, I agree #15506 would become superfluous.

@seberg
Copy link
Copy Markdown
Contributor

seberg commented Oct 24, 2023

From the logs, it looks like this is working but what I can't tell is if there is a way to find out for a given wheel what version of Numpy it was built against, to double check.

Unfortunately, I don't have a great advise here right now. The problem is that you only really see which version is it when you try to import a newer NumPy and it refuses.

If you want something viable today, you can use the NumPy 2.0 nightly wheel and:

import numpy.core._multiarray_umath; numpy.core._multiarray_umath._ARRAY_API = None
import astropy

If it works, you are building with NumPy 2.0, if it fails you are building with NumPy 1.x.

We were discussing whether we could create a tool that does that in a way that it fails to see which version you compiled for, but that needs some hacking and it doesn't exist yet (I am not certain it will actually be easy to do that). I doubt that is super relevant for you, it is mainly something the conda folks would like to test their builds.

EDIT: A note in case someone finds this. The above hack I gave will fail if you use pybind11 because it ships its custom _import_array() logic. There is no reason to worry: pybind11 will certainly be fixed by the time it matters.

@astrofrog
Copy link
Copy Markdown
Member Author

Why only do this for scheduled or dispatched events? Shouldn't we be consistent? That is, if I apply "build all wheels" label on a PR, I would expect the same thing to happen, except no wheel upload.

Ok I've now switched it to use the 'dev' build dependencies when doing 'Build all wheels'. Note that at least we will still have a build against the latest stable version in the test_wheel_building job which happens in any case regardless of the label.

I think we'd still want to check that the wheels we build work with stable numpy, no?

The test_wheel_building will always be run in a PR and will test the regular build isolation with stable numpy.

Note that in all cases, the tests are run using the latest stable numpy, not dev numpy.

@astrofrog
Copy link
Copy Markdown
Member Author

Ah we need to release https://github.com/OpenAstronomy/github-actions-workflows/releases/tag/untagged-6c0ffc9148fcf9a95fe5 for this to work properly here.

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Oct 24, 2023

Note that in all cases, the tests are run using the latest stable numpy, not dev numpy.

OK, I now see that that works, indeed, since you just install the wheel with the regular+test dependencies.

@astrofrog astrofrog force-pushed the cibuildwheel-dev-numpy branch from b599b82 to 9545209 Compare October 24, 2023 19:18
@astrofrog
Copy link
Copy Markdown
Member Author

Also I think this only solves half our problem. We also need pyerfa dev that is built against numpy-dev, no? xref liberfa/pyerfa#109

Yes I can always try and set up dev wheels of pyerfa, but that's separate as pyerfa isn't a build-time dependency of astropy so not within the scope of this PR.

Copy link
Copy Markdown
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can give it a try and see. Thanks!

@pllim
Copy link
Copy Markdown
Member

pllim commented Oct 24, 2023

Not sure what's up w.r.t. your comment on OpenAstronomy so I'll let you merge when you think this is ready.

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Oct 24, 2023

Yes I can always try and set up dev wheels of pyerfa, but that's separate as pyerfa isn't a build-time dependency of astropy so not within the scope of this PR.

On the astropy side, I guess the alternative would be building erfa in the regular numpy-dev run, right?

@astrofrog astrofrog merged commit 7a50223 into astropy:main Oct 24, 2023
@astrofrog
Copy link
Copy Markdown
Member Author

@pllim - @Cadair released a new version of the workflows and everything works here now.

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Oct 24, 2023

Thanks, @astrofrog! Really nice.

@astrofrog
Copy link
Copy Markdown
Member Author

@pllim - I have triggered a build of the dev wheels:

https://github.com/astropy/astropy/actions/runs/6632806493

Once that is done we can try what @seberg suggested in #15524 (comment) (I might not be able to get to it for a couple of days so feel free to try it if you like)

@astrofrog
Copy link
Copy Markdown
Member Author

@seberg I tried your suggestion with the latest dev wheels which have now been uploaded, and using:

pip install --extra-index-url https://pypi.anaconda.org/astropy/simple astropy --pre --upgrade

but import astropy fails after setting ..._ARRAY_API = None. I'll need to try and see if I can improve the vebosity of the cibuildwheel builds to check what version of numpy it is downloading.

@astrofrog
Copy link
Copy Markdown
Member Author

Fix in #15533

@astrofrog
Copy link
Copy Markdown
Member Author

@seberg @pllim @mhvk - there are now nightly wheels for pyerfa which can be installed from https://pypi.anaconda.org/liberfa/simple – if I do:

rm -rf test-dev
python -m venv test-dev
source test-dev/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 freeze
python -c 'import numpy.core._multiarray_umath; numpy.core._multiarray_umath._ARRAY_API = None; import astropy'

there is now no longer an error in the last command! 🎉

@seberg
Copy link
Copy Markdown
Contributor

seberg commented Oct 27, 2023

Awesome, thanks!

A note in case someone finds this. The above hack I gave will fail if you use pybind11 because it ships its custom _import_array() logic. There is no reason to worry: pybind11 will certainly be fixed by the time it matters.

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Oct 27, 2023

Thanks so much, @astrofrog!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants