Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: reintroduce compatibility shim for compiling against numpy 1.x #147

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

neutrinoceros
Copy link
Contributor

This reverts a cleanup I did rather eagerly in #144, and re-introduces a compatibility shim originally added in #140
Rationale: even if we're now requiring numpy>2.0.0rc in pyproject.toml, this bit of meta data is ignored by pip when installing with --no-build-isolation. On old and exotic architectures, where numpy 2.0.0rc1 isn't available, it's not problematic to build against 1.x instead, and can save the (long) time required to build numpy itself (if it even works).
In short, this would replace astropy/astropy#16284

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

OK, makes sense - there is no reason to, effectively, forbid building against earlier numpy; I think this part really teaches a lesson that if we support earlier numpy, we should also support building against it. Indeed, we may want to add a test in our CI that ensures this actually works. Is that easy to add? If not, I'm happy to just merge this now.

@mhvk
Copy link
Contributor

mhvk commented Apr 11, 2024

p.s. It is not directly related, but I do feel that there now is even more reason not to enforce minimum versions in pyproject.toml, but rather do those in our wheel builds.

@mhvk
Copy link
Contributor

mhvk commented Apr 11, 2024

p.s. It is not directly related, but I do feel that there now is even more reason not to enforce minimum versions in pyproject.toml, but rather do those in our wheel builds.

In fact, don't we have to remove the constraint in pyproject.toml so that the unusual archs can just work in astropy without requiring special flags?

@neutrinoceros
Copy link
Contributor Author

In fact, don't we have to remove the constraint in pyproject.toml so that the unusual archs can just work in astropy without requiring special flags?

not if they skip build-isolation, which is the workflow that I'm trying to fix here :)

@neutrinoceros
Copy link
Contributor Author

Is that easy to add? If not, I'm happy to just merge this now.

Sorry I missed that. I think it may be easy, I'll give it a try now.

@neutrinoceros neutrinoceros marked this pull request as draft April 11, 2024 15:07
@neutrinoceros
Copy link
Contributor Author

I just force-pushed with just the new CI job so we can see it failing first.

@neutrinoceros neutrinoceros force-pushed the bld/numpy_1.x_compat_shim branch 2 times, most recently from fd1ebb4 to 68beb3a Compare April 11, 2024 15:14
@neutrinoceros
Copy link
Contributor Author

(of course it needs to fail for the expected reason. I'll iterate until I get it right)

@neutrinoceros neutrinoceros force-pushed the bld/numpy_1.x_compat_shim branch 3 times, most recently from af7814b to 96d34c0 Compare April 11, 2024 15:28
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
Copy link
Contributor

Choose a reason for hiding this comment

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

It still seems to me we're papering over the main problem, that this all comes about because we have the requirement of numpy>=2.0.0rc1 in pyproject.toml. At least, it looks to me that, as is, a pip install pyerfa on the astropy side for s390 etc will still force installation of numpy 2.0 to produce the pyerfa binaries and thus fail (unless we add --no-build-isolation there too, but why should astropy have to worry about this?).

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess to put it a bit more constructively, I think this test should verify that pip install pyerfa is possible on a system that does not have numpy 2.0 (and cannot build it either).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I see it, it's only a trade-off for where we want things to be simple and where we accept that they get more complicated.
Having numpy>=2.0.0rc1 gives a behavior that's almost always desirable, and crucially, doesn't prevent working with numpy 1.x when needed. Whereas not having it moves the complexity to something much more crucial: the releasing process. I personally feel it's preferable to put the extra workload on rare archs.

Copy link
Contributor

Choose a reason for hiding this comment

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

My problem is that we're making problems on rare archs outside of our own package - I dislike that astropy has to work around a choice of convenience made in pyerfa.

I also generally dislike that we effectively state falsehoods: numpy>=2.0.0.rc1 is in fact not required to build pyerfa; it is just something that's there because it can help create a package that is useful in more circumstances (which for a general pip install is likely irrelevant).

Anyway, this is slightly orthogonal to the issue at hand, which really just reflects that pip is not a great package manager (and that creating a good package manager is incredibly hard). Let's first of all make sure astropy can build at all!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's first of all make sure astropy can build at all!

To be clear, astropy has no build issue. What's broken is building pyerfa on rare arch's without numpy 2, and it happens that this is only tested in the astropy repo

Copy link
Contributor

Choose a reason for hiding this comment

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

What's broken is building pyerfa on rare arch's without numpy 2

Indeed, and my suggestion was mostly meant to ensure that on the astropy side one doesn't have to give any special flags to get pyerfa to build properly when numpy 2.0 is not available.

But obviously without reintroducing the *elsize* stuff that will not be possible at all, so let's get that in first!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ready when you are :)

@neutrinoceros neutrinoceros marked this pull request as ready for review April 11, 2024 15:43
@mhvk
Copy link
Contributor

mhvk commented Apr 11, 2024

OK, let's get this in so we can unblock astropy. We can discuss the build requirements elsewhere.

@mhvk mhvk merged commit 078ae11 into liberfa:main Apr 11, 2024
24 checks passed
@neutrinoceros neutrinoceros deleted the bld/numpy_1.x_compat_shim branch April 12, 2024 08:01
@neutrinoceros
Copy link
Contributor Author

@mhvk just to make sure we're on the same page; a release with this patch would be needed to actually unblock astropy's weekly cron.

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

@mhvk
Copy link
Contributor

mhvk commented Apr 12, 2024

OK, I pushed a changelog entry and new tag, so the next version is being created: https://github.com/liberfa/pyerfa/actions/runs/8664641913

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

Thanks! I see it on PyPI. Should we yank 2.0.1.3 too? 🤷‍♀️

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

I triggered the exotic archs job for astropy. I'll let you know in a few hours. 😆 🤞

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

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

Ooops sorry, looks like they don't listen to workflow_dispatch for some reason (PR for another time) so I am rerunning the scheduled one here instead: https://github.com/astropy/astropy/actions/runs/8595346105

@mhvk
Copy link
Contributor

mhvk commented Apr 12, 2024

Should we yank 2.0.1.3 too? 🤷‍♀️

Not sure what is best practice, but the wheels for 2.0.1.3 did work properly, for all supported versions of numpy, so my sense is that there is no need to yank. But let's ping @astrofrog.

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

wheels for 2.0.1.3 did work properly, for all supported versions of numpy

Hmm. Then why did it crash for 3 of the 4 "exotic" archs over at astropy? 🤔

@neutrinoceros
Copy link
Contributor Author

Only building from source against numpy 1.x was broken, I don't think it warrants a yank, especially now that there's a new latest release.

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

Okay then, thanks for the clarification!

@pllim
Copy link
Contributor

pllim commented Apr 12, 2024

main passed now https://github.com/astropy/astropy/actions/runs/8595346105

v6.1.x also passed https://github.com/astropy/astropy/actions/runs/8663207597

Thanks for the quick fix and release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants