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

Cython 3 and numpy 2 #3290

Closed
wants to merge 21 commits into from
Closed

Cython 3 and numpy 2 #3290

wants to merge 21 commits into from

Conversation

connorjward
Copy link
Contributor

@connorjward connorjward commented Dec 11, 2023

Description

Fixes #3081

It will also allow us to update our PETSc fork as petsc4py now requires cython 3.

@connorjward
Copy link
Contributor Author

I was wrong to assume that this would be simple. In order for Cython 3 to work for us we need to also install numpy 1.26 (as older numpys do not work with Cython 3). This has a number of issues:

  • We would need to drop support for Python 3.8, not a big issue
  • numpy 1.26 seems like a strange Frankenstein release. The pyproject.toml is a bit crazy for example.

@JDBetteridge, you were completely right about this being a hard problem. I vote that we wait for numpy 2.0 to land when the build system is sane again.

However, I hope it's at least helpful that I've fixed dmcommon.pyx so that it's compatible! I'll leave this PR open for reference/later use.

@@ -983,14 +982,10 @@ def run_pip_install(pipargs):
# subprocesses wrote out.
# Particularly important for debugging petsc fails.
with environment(**blas):
pipargs = ["-vvv"] + pipargs
pipargs = ["-v"] + pipargs
Copy link
Member

Choose a reason for hiding this comment

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

😂

@connorjward
Copy link
Contributor Author

@Ig-dolci FYI I am having another stab at this now. If we use the release candidate for numpy 2.0 then we can hopefully land Cython 3 and numpy at the same time.

@connorjward
Copy link
Contributor Author

This is quite the pain, now loopy is also having issues.

@connorjward connorjward changed the title Fix cython files for Cython 3.0 Cython 3 and numpy 2 Apr 12, 2024
@connorjward connorjward marked this pull request as ready for review April 17, 2024 08:21
@@ -1347,8 +1334,9 @@ def build_and_install_torch():
raise InstallError("CUDA installation is not available on MacOS.")
if sys.version_info >= (3, 10):
run_pip_install(["typing_extensions"])
extra_index_url = ["--extra-index-url", "https://download.pytorch.org/whl/cpu"] if args.torch == "cpu" else []
run_pip_install(["torch"] + extra_index_url)
# FIXME: use nightly to see if that makes numpy 2.0 happy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should really be

pip install torch==2.3.0 --index-url https://download.pytorch.org/whl/test/cpu

as detailed in https://dev-discuss.pytorch.org/t/pytorch-release-2-3-0-final-rc-is-available/1995

2.3.0 is supposed to be released 24/04.

@francesco-ballarin
Copy link
Member

francesco-ballarin commented Apr 17, 2024

Just to double check: are the numpy changes here backward compatible with 1.x, or not?

cython 3.x is somewhat widespread now, while it will still take a while to get numpy 2.x widely used (at least, on installations that do not use firedrake-install)

@connorjward
Copy link
Contributor Author

Just to double check: are the numpy changes here backward compatible with 1.x, or not?

cython 3.x is somewhat widespread now, while it will still take a while to get numpy 2.x widely used (at least, on installations that do not use firedrake-install)

I think so. The errors fixed here were mostly due to numpy dropping support for deprecated API.

@JDBetteridge JDBetteridge marked this pull request as draft June 4, 2024 14:46
@francesco-ballarin
Copy link
Member

Will this be closed in favor of #3546?

@connorjward
Copy link
Contributor Author

Will this be closed in favor of #3546?

Yes.

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.

BUG: cythonizing firedrake/cython/dmcommon.pyx fails with cython 3.0+
3 participants