Skip to content

Support GraalPy #1538

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

Merged
merged 11 commits into from
Apr 28, 2025
Merged

Support GraalPy #1538

merged 11 commits into from
Apr 28, 2025

Conversation

timfel
Copy link
Contributor

@timfel timfel commented Jun 28, 2023

This PR adds support for GraalPy.

A couple of questions:

  1. GraalPy is not included in manylinux images, so I added a facility to download Pythons there as well. Does that seem ok?
  2. I couldn't find a way to exclude GraalPy by default - I'm not sure, but maybe it would be good to be conservative here and let people opt-in to building wheels on GraalPy via the CIBW_BUILD variable explicitly.

@timfel timfel force-pushed the graalpy branch 5 times, most recently from ad26df1 to ab43cbb Compare July 2, 2023 11:43
@henryiii
Copy link
Contributor

henryiii commented Jul 8, 2023

GraalPy is not included in manylinux images

Would it make sense to include it?

I couldn't find a way to exclude GraalPy by default

Maybe it's time to think about adding this. It comes up occasionally. I'd like to also remove pypy37 and pypy38 from the default, as they are no longer supported by upstream.

@joerick
Copy link
Contributor

joerick commented Jul 9, 2023

GraalPy is not included in manylinux images

Would it make sense to include it?

It would certainly be neater if it was included. Also, I've never heard of GraalPy, so I can't assess wether it's inclusion and maintenance here would be worth it for users. If Manylinux were to adopt it, that would make the decision much easier!

I couldn't find a way to exclude GraalPy by default

Maybe it's time to think about adding this. It comes up occasionally. I'd like to also remove pypy37 and pypy38 from the default, as they are no longer supported by upstream.

Hm. Yes, agreed. It would also allow us to soft-drop EoL CPythons, while keeping the functionality. The simplest way to do this would be to set a default for CIBW_BUILD. E.g. the default could be CIBW_BUILD=cp* pp{39,310}-*. One downside of this would be some projects (example) set CIBW_BUILD to *, for example, in a matrix where some other configurations are set. The fix in such cases, I suppose, would be to set to empty string instead "". On the upside, it does change the default as we want, and doesn't add additional complexity.

@timfel
Copy link
Contributor Author

timfel commented Jul 12, 2023

GraalPy is not included in manylinux images

I was under the assumption that manylinux (like e.g. conda) wants to build everything into their images from source, but now I see that they also just download PyPy binaries and put them in there, so I can open a PR there to do the same for GraalPy. This will simplify this PR.

The simplest way to do this would be to set a default for CIBW_BUILD [...] the default could be CIBW_BUILD=cp* pp{39,310}-*

That's what I also thought. I did this, which is just skipping any Python specifier starting with g. Rather than a negative match which may exclude too much (with fnmatch we cannot do curly brace expansion iirc, so cannot exclude gp), a positive default may be a good idea, but I'm the wrong person to decide that :)

@joerick
Copy link
Contributor

joerick commented Aug 30, 2023

Converting to draft until manylinux support lands.

@mayeut
Copy link
Member

mayeut commented Jun 22, 2024

manylinux support has landed. It will be available in cibuildwheel once the update workflow runs & gets merge.

@timfel
Copy link
Contributor Author

timfel commented Jul 17, 2024

I've updated the PR to use the manylinux support, but in the meantime uv has become included in manylinux and used by default, and that doesn't support GraalPy, yet. See also astral-sh/uv#5141

@timfel
Copy link
Contributor Author

timfel commented Jul 19, 2024

uv now supports GraalPy on main, once the next release is out we need to include it in manylinux images and then I'll revisit this PR

@mayeut
Copy link
Member

mayeut commented Jul 20, 2024

Unfortunately, the new version of uv still does not work on manylinux (I commented in the uv PR with more details).
@timfel, you can opt-out from using uv with graalpy for now, c.f. #1941 for a sample opting out PyPy 3.8 on Windows.

@timfel timfel force-pushed the graalpy branch 3 times, most recently from 5dfb310 to 69760d9 Compare July 21, 2024 04:05
@timfel timfel force-pushed the graalpy branch 3 times, most recently from 60b55f6 to c012a0f Compare September 17, 2024 14:58
@joerick
Copy link
Contributor

joerick commented Jan 20, 2025

@timfel, I don't know if you're still actively working on this, but we have a v3.0 release coming up, which would be a perfect time to land a feature like this!

@timfel
Copy link
Contributor Author

timfel commented Jan 20, 2025

@timfel, I don't know if you're still actively working on this, but we have a v3.0 release coming up, which would be a perfect time to land a feature like this!

What is the timeframe for 3.0? We are still working on this, but needed a few fixes in tox, uv, and virtualenv to go in first. The virtualenv fix is still not merged because we can only pass it with the new GraalPy release that is due out in March

@joerick
Copy link
Contributor

joerick commented Jan 22, 2025

Ah, I didn't realise there were blockers.

What is the timeframe for 3.0?

No definitive timeline, (when it's ready ;) ) but probably some time over the next few weeks.

@joerick
Copy link
Contributor

joerick commented Jan 22, 2025

March is probably too far out for us to hold the 3.0 release for specifically. Not a problem, it can arrive in a point update, I just thought it would be neat :)

@joerick
Copy link
Contributor

joerick commented Apr 11, 2025

Something we need to consider: how this impacts CI times. It's considerable-

main this PR
ubuntu-latest (3.13) 37min 65min
macOS-13 (3.13) 32min 43min
windows-latest (3.13) 49min 77min

Perhaps there's a way we can flag what's enabled for an integration test run - e.g. don't run the test suite on all the EnableGroups by default? The test duration is less important on main, but it does affect how fast we can move in PRs.

@joerick
Copy link
Contributor

joerick commented Apr 13, 2025

Perhaps this is a good model to copy - pyodide-build has this code in their CI config to add flags to their tests based on PR labels pyodide/pyodide-build@794ed7a

@joerick
Copy link
Contributor

joerick commented Apr 13, 2025

I've drawn up that approach in #2357

@timfel
Copy link
Contributor Author

timfel commented Apr 15, 2025

I've drawn up that approach in #2357

This looks very reasonable to me :-) Will you let me know if/when I should rebase this PR on top of that one?

@henryiii
Copy link
Contributor

henryiii commented Apr 15, 2025

@timfel
Copy link
Contributor Author

timfel commented Apr 15, 2025

We don't release Windows arm binaries of GraalPy so far, so as long as it is not enabled for that platform it's fine.

@henryiii henryiii force-pushed the graalpy branch 2 times, most recently from 7bba507 to 7446d63 Compare April 15, 2025 19:07
@henryiii
Copy link
Contributor

Doesn't seem to be causing a problem after rebasing, so I think it's fine.

Comment on lines 44 to 60
assert "WARNING: Running pip as the 'root' user can result" not in stream
# manylinux-interpreters ensure will run pip on GraalPy as the root
# user once, so we will get the warning below. We make sure it is only
# because of manylinux and nothing else. We do this by checking that
# the error message only occurs directly after a call to graalpy's
# ensurepip in the manylinux `/opt/` directory
start = 0
bad_msg = "WARNING: Running pip as the 'root' user can result"
assert_msg = f"{bad_msg} is only tolerated from manylinux's ensure for graalpy"
for m in re.finditer(bad_msg, stream):
idx = stream.rfind("/opt/", start, m.end())
start = m.end()
m2 = re.match(
"/opt/.*/graalpy.*/bin/python -m ensurepip --default-pip", stream[idx : m.start()]
)
assert m2 is not None, assert_msg
assert idx + m2.end() + 1 == m.start(), assert_msg
Copy link
Member

Choose a reason for hiding this comment

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

In light of the much longer CI times, I'm checking how not excluding graalpy from image warm-up impacts CI time on Linux, which would most likely make this workaround no-op:

diff --git a/test/conftest.py b/test/conftest.py
index 8c0c9504..f2b575df 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -56,9 +56,8 @@ def docker_warmup(request: pytest.FixtureRequest) -> None:
     images = [build_options.manylinux_images[arch] for arch in archs] + [
         build_options.musllinux_images[arch] for arch in archs
     ]
-    # exclude GraalPy as it's not a target for cibuildwheel
     command = (
-        "manylinux-interpreters ensure $(manylinux-interpreters list 2>/dev/null | grep -v graalpy) &&"
+        "manylinux-interpreters ensure-all &&"
         "cpython3.13 -m pip download -d /tmp setuptools wheel pytest"
     )
     for image in images:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied in a47e354 and I removed this workaround in the same commit.

@mayeut
Copy link
Member

mayeut commented Apr 19, 2025

Something we need to consider: how this impacts CI times. It's considerable-

Updating warm-up on Linux images allows to reduce CI times on Linux.

main this PR Linux warm-up
ubuntu-latest (3.13) 39min 66min 50min
ubuntu-24.04-arm (3.13) 24min 42min 34min
macOS-13 (3.13) 29min 48min N/A
macOS-15 (3.13) 21min 29min N/A
windows-latest (3.13) 47min 65min N/A

@joerick
Copy link
Contributor

joerick commented Apr 28, 2025

Let's apply @mayeut's patch here then, and if we can get the conflicts sorted I think this is ready. @timfel would you be able to do that? We'll merge #2357 afterwards.

@timfel
Copy link
Contributor Author

timfel commented Apr 28, 2025

Let's apply @mayeut's patch here then, and if we can get the conflicts sorted I think this is ready. @timfel would you be able to do that? We'll merge #2357 afterwards.

I'll look at the conflicts

Sorry, I think I misunderstood your message, you meant me to apply @mayeut's patch, right @joerick? That's what I did now plus rebase.

@henryiii henryiii merged commit 020a91b into pypa:main Apr 28, 2025
27 checks passed
@henryiii
Copy link
Contributor

Thanks!

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