Skip to content

Build: Replace oldest-supported-numpy - #14949

Merged
pllim merged 1 commit into
astropy:mainfrom
pllim:drop-oldest-supported-numpy
Aug 18, 2023
Merged

pllim merged 1 commit into
astropy:mainfrom
pllim:drop-oldest-supported-numpy

Conversation

@pllim

@pllim pllim commented Jun 14, 2023

Copy link
Copy Markdown
Member

Description

This pull request is to replace oldest-supported-numpy with numpy 1.25 that guarantee backward compatible C-API.

Fixes #14915

@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 "When to rebase and squash commits".
  • 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.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

Comment thread pyproject.toml Outdated
"setuptools_scm>=6.2",
"cython==0.29.34",
"oldest-supported-numpy",
"numpy==1.25",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this should be >=1.25

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this should perhaps also include <2 though I haven't had time to check if the backward compatibility is 'forever' or could break in 2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"A major release is highly unusual (NumPy is still at version 1.xx) and if it happens it will likely indicate an ABI break"

I think we should perhaps do >=1.25,<2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought someone once said that we should always do == pins on the build requirements? Isn't that why we do == for cython? Then why cython but not numpy?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed about the >=1.25,<2.0 pin for Numpy,
For Cython, Numpy uses Cython>=0.29.34,<3.0 which seems better to me than pinning a specific version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmmmpf, I guess you will have to compile it against our dev wheel, you don't even have to pass tests on it to do that.

The problem is, only if you use the 2.x wheel, can I provide updated headers to ensure compatibility (and force you to remove API that is I want to stop dragging around).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, somehow slipped me: Right now, NumPy doesn't actually enforce this! For precisely that reason. As long as we just remove things for the most part, I am happy to gamble that the wheels are effectively ABI compatible (even if that is a lie).

There might come a day where we want to do something that makes this impossible, but I am not sure that will come...
As soon as there is an actual NumPy rc1, that would be enforced though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

you will have to compile it against our dev wheel

I guess it is theoretically possible for our unreleased 6.0.dev. But we cannot do that for release branches; so does this mean we have to pin numpy maxversion for v5.3.x ? Though I also have no seen any failures related to this in our CI set up. My head hurts. 😆

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the info, @seberg ! I'll see what @astropy/astropy-project-release-team has to say since they are the ones doing releases. 🤞

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, yes, just repeating in case it got lost: The NumPy dev wheels do not actually enforce this, they just pretend they are still 1.x ABI (it's a lie, but who cares). Maybe that will just stay that way, maybe I will find a big enough reason to break that "promise".

@Cadair Cadair added the Build all wheels Run all the wheel builds rather than just a selection label Jun 15, 2023
@pllim
pllim force-pushed the drop-oldest-supported-numpy branch from 4a0d0af to c7e3bf8 Compare June 20, 2023 14:45
@pllim
pllim marked this pull request as ready for review June 20, 2023 15:20
@saimn

saimn commented Jun 20, 2023

Copy link
Copy Markdown
Contributor

Ideally we should also use

#define NPY_TARGET_VERSION NPY_1_21_API_VERSION

but I don't think we have an easy way to do that right now with extension-helpers ...

@saimn

saimn commented Jun 20, 2023

Copy link
Copy Markdown
Contributor

Actually might be easy to do by looping on the result of get_extensions()
https://github.com/astropy/astropy/blob/main/setup.py#L69

@pllim

pllim commented Jun 20, 2023

Copy link
Copy Markdown
Member Author

@saimn , do you want to take over? You probably knows exactly what to do in the loop and stuff. Thanks!

@Cadair

Cadair commented Jun 20, 2023

Copy link
Copy Markdown
Member

Actually might be easy to do by looping on the result of get_extensions() https://github.com/astropy/astropy/blob/main/setup.py#L69

This is nasty 😆

Extension helpers has the ability to drop the setup.py file completely now, so relying on logic in there is a bad idea. I don't have an alternative for you though so 🤷

@pllim
pllim force-pushed the drop-oldest-supported-numpy branch from 0cd824f to 6fd7ebd Compare June 20, 2023 16:16
@saimn

saimn commented Jun 20, 2023

Copy link
Copy Markdown
Contributor

Well there are various things for which a setup.py is still necessary, cython coverage, profiling, debugging...

@astrofrog

astrofrog commented Jun 20, 2023 •

Copy link
Copy Markdown
Member

Can't we just add an option in extension helpers to do this automatically for all extensions if it's going to be something common?

@saimn

saimn commented Jun 22, 2023

Copy link
Copy Markdown
Contributor

@astrofrog - Yes, I guess this could be done.

Comment thread setup.py
# Specify the minimum version for the Numpy C-API
for ext in ext_modules:
if ext.include_dirs and "numpy" in ext.include_dirs[0]:
ext.define_macros.append(("NPY_TARGET_VERSION", "NPY_1_21_API_VERSION"))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does it crash if the extension code already has its own NPY_TARGET_VERSION somehow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also... so much for getting rid of setup.py lol

@pllim

pllim commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

So... Are we keeping the stuff in setup.py here or no? I got lost in the discussions.

@pllim

pllim commented Aug 18, 2023 •

Copy link
Copy Markdown
Member Author

I am revisiting Python 3.12 related stuff. I realized that some upstream stuff with oldest-supported-numpy is giving us troubles if we have to build them from source. So this means we're affecting our downstream the same way if for whatever reason they cannot use our dev wheels (we don't have py312 wheels yet but I want to make it happen).

tl;dr -- Can I merge this???

@astrofrog astrofrog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Go forth and merge! I will think about how to avoid the setup.py code here, I think we can do it via extension-helpers. But this is fine for now.

@pllim

This comment was marked as resolved.

with numpy 1.25 that guarantee backward compatible C-API.

But we do not want exact pin.

Specify the minimum version for the Numpy C-API

Co-authored-by: Simon Conseil <[email protected]>
@pllim
pllim force-pushed the drop-oldest-supported-numpy branch from a208132 to 6aba670 Compare August 18, 2023 16:45
@pllim pllim mentioned this pull request Aug 18, 2023
6 tasks done
@pllim pllim added the Extra CI Run cron CI as part of PR label Aug 18, 2023
@pllim

pllim commented Aug 18, 2023

Copy link
Copy Markdown
Member Author

Let's run all the exotic stuff too, just in case.

Comment thread pyproject.toml
"setuptools_scm>=6.2",
"cython==0.29.34",
"oldest-supported-numpy",
"numpy>=1.25,<2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would recommend adding a temporary version cap on the runtime dependency as well, see scipy/oldest-supported-numpy#76 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You mean install_requires? But then we won't be able to test against numpy dev in CI, no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes I mean install_requires, and it won't be blocking for future-compatibility tests because 2.0.0dev0 compares as < 2.0 :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So you are guarding against... numpy 3.0?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nope, against 2.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess I do not understand the logic of allowing 2.0.dev but preventing users from using the actual 2.0 later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for your concern, which is valid. But I would like to discuss it separate from this one. Can you please propose a PR at your convenience?

I don't mind max pinning numpy in release branches, but I would rather not do it in the main branch. I think scipy only pin maxversion when they branch for release (at least the last I look and I don't look very often).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

done at #15206 !

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

Labels

Build all wheels Run all the wheel builds rather than just a selection build Extra CI Run cron CI as part of PR installation no-changelog-entry-needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop oldest-supported-numpy from build requirements when numpy 1.25 is released

6 participants