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

Updating numpy.i (cvxcore) swig interface #2392

Merged
merged 10 commits into from
Jun 4, 2024

Conversation

Transurgeon
Copy link
Contributor

@Transurgeon Transurgeon commented Mar 31, 2024

Description

This PR updates the cvxpy build to allow compatible wheels with NumPy 2.0.
The changes come in the following stages:

  • updating the numpy.i file in cvxcore which is used for the swig interface. (As pointed out by Riley in the corresponding issue linked below). The new file is taken from here and was last updated 2 years ago.
  • Rebuild cvxcore using the swig command in the corresponding README located here.

So I believe the updates to cvxcore are necessary for wheels compatibility with NumPy 2.0.
Any feedback/questions are welcome!

P.S: I am quite new to the python build ecosystem so I may have missed some important steps.

Issue link (if applicable): #2389

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Transurgeon seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

cvxpy/cvxcore/python/cvxcore.py Outdated Show resolved Hide resolved
cvxpy/cvxcore/python/cvxcore.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@Transurgeon
Copy link
Contributor Author

Transurgeon commented Apr 4, 2024

I tried to follow the steps outlined in the NumPy migration guide, but could have certainly missed some steps.
I think the next steps for this would be to update the CI to test both on the oldest numpy version and the nightly version of NumPy.
Another option could just be to wait until NumPy 2.0 is officially released through pip. (see image below)
image

@PTNobel
Copy link
Collaborator

PTNobel commented May 13, 2024

Another option could just be to wait until NumPy 2.0 is officially released through pip. (see image below)

I think that's my preference tbh... I don't think we're in a huge rush to get this merged and I feel like we'll be far from the only package that is broken right after 2.0 drops.

@Transurgeon
Copy link
Contributor Author

@PTNobel @SteveDiamond @rileyjmurray
I propose that we first merge this PR without the changes to thepyproject.toml setup file, that way the CI will pass and we can figure out later how we want to go about testing the new builds.
I'll also change the title of the PR to something like "updating numpy.I swig interface".

This could also maybe allow the cvxpy-feedstock to rebuild without any problems.

What are your thoughts?

@PTNobel
Copy link
Collaborator

PTNobel commented May 25, 2024

That sounds like a great first step. I think I agree with h-vetenari in another thread that we should release 1.5.2 with NumPy 2.0 support before 2.0 comes out. That'll mean some changes to the GitHub action runners

@Transurgeon Transurgeon changed the title Prep cvxpy for NumPy 2.0 release Updating numpy.I (cvxcore) swig interface May 25, 2024
@Transurgeon
Copy link
Contributor Author

Ok, I just reverted the changes to pyproject.toml. CI failure seems to be unrelated to the PR.

@PTNobel PTNobel self-assigned this May 28, 2024
@PTNobel
Copy link
Collaborator

PTNobel commented May 28, 2024

I want to make sure that the cvxpy-base build is working before merging... Rerunning CI, since the error seemed spurious

Copy link
Collaborator

@PTNobel PTNobel May 28, 2024

Choose a reason for hiding this comment

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

I'm not a huge fan of downgrading our swig version. I had thought we had updated to fix a bug; William can you update the swig on your computer and rerun this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried rerunning the command, but to no avail. I also couldn't find a way to upgrade the swig version (sorry! I am very unfamiliar with swig).

I decided to just revert the changes to the file since it seems like it was already generated using the desired swig 4.1.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I just managed to install swig 4.2.1 (the latest). And regenerated the cvxcore wrap file. Everything seems to work now :).

@PTNobel
Copy link
Collaborator

PTNobel commented May 28, 2024

Upgrading to Swig 4.1.1 was quite intentional. I don't think we should backout #2273

@PTNobel PTNobel changed the title Updating numpy.I (cvxcore) swig interface Updating numpy.i (cvxcore) swig interface May 28, 2024
@Transurgeon
Copy link
Contributor Author

Upgrading to Swig 4.1.1 was quite intentional. I don't think we should backout #2273

Sorry, I wasn't aware of that PR.

I just tried rebuilding cvxpy with numpy 2.0, but it didn't work. So we do need to rerun the given command with a newer version of swig.

Anaconda only provides swig 4.0.2, see here: https://anaconda.org/anaconda/swig. Same thing for homebrew. (This means we should probably update the instructions in the cvxcore README as well).

I found the releases on the swig GitHub, see here: https://github.com/swig/swig/tags. Would we potentially want to update to the latest version which is 4.2.1?

@Transurgeon
Copy link
Contributor Author

@PTNobel could you have another look at this PR please?

I managed to install the newest swig version and regenerated the cvxcore wrap file (it is now version 4.2.1).
I then retried to build cvxpy with numpy 2.0 and it seems to work without any problems.
Finally, I updated the cvxcore/README.md to reflect anaconda being outdated on the swig version.

@PTNobel
Copy link
Collaborator

PTNobel commented Jun 1, 2024

Looks good to me

Copy link
Collaborator

@phschiele phschiele left a comment

Choose a reason for hiding this comment

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

Let's see if this works with the pre-release CI!

@phschiele phschiele merged commit 49b5cbf into cvxpy:master Jun 4, 2024
50 checks passed
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.

None yet

4 participants