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

Support GraalPy #1538

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Support GraalPy #1538

wants to merge 9 commits into from

Conversation

timfel
Copy link

@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
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
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
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
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 :)

@henryiii
Copy link
Contributor

henryiii commented Apr 1, 2025

Wild guess: is it trying to build for both 32-bit and 64-bit on Windows, but actually producing the 64-bit wheels both times? I see that's a cp wheel, maybe it's not picking up the GraalPy tag?

@henryiii
Copy link
Contributor

henryiii commented Apr 2, 2025

Does GraalPy support the stable ABI? I see one test failing for that, I'd assume it's not supported. I also see <frozen graalpy.pip_hook>:48: RuntimeWarning: You are using an untested version of pip. GraalPy provides patches and workarounds for a number of packages when used with compatible pip versions. We recommend to stick with the pip version that ships with this version of GraalPy. but maybe that's on one of the pinning tests?

@henryiii
Copy link
Contributor

henryiii commented Apr 3, 2025

It looks to me that gp* is not producing a graalpy wheel, but instead the host Python's wheel.

+ python --version
GraalPy 3.11.7 (Oracle GraalVM Native 24.2.0)
...
+ python -m build 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-2\\popen-gw2\\test0\\project' --wheel '--outdir=C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-sxknk4dt\\gp242-win_amd64\\built_wheel' --no-isolation
* Getting build dependencies for wheel...
stored_version 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)]
sys.version 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)]
...
Successfully built spam-0.1.0-cp313-cp313-win_amd64.whl

Could this be an issue with build? Since this is a Windows issue, I guess I can't just use setup-python to test it in pypa/build's test suite.

@timfel
Copy link
Author

timfel commented Apr 3, 2025

Could this be an issue with build? Since this is a Windows issue, I guess I can't just use setup-python to test it in pypa/build's test suite.

Yes, GraalPy has a few bugs on Windows when using build. I got past most of them now I think, failed at 98% of the tests just earlier so I hope I'll have this ready by tomorrow.

@timfel
Copy link
Author

timfel commented Apr 3, 2025

Ok, everything green now in Github actions. Let's see if circleci and azure agree :)

@henryiii
Copy link
Contributor

henryiii commented Apr 3, 2025

Looks like it's hitting a "couldn't find uv" error. Our tests run with or without uv. Is uv required? We could skip if it's not present.

@timfel
Copy link
Author

timfel commented Apr 4, 2025

Looks like it's hitting a "couldn't find uv" error. Our tests run with or without uv. Is uv required? We could skip if it's not present.

Ah, yeah, I linked oracle/graalpython#491 - we have a bug when build uses virtualenv and isolation for building only on Windows, so my workaround was to force using uv with GraalPy on Windows. I guess we'll have to skip then.

Only when building the GraalPy wheels on windows with build[virtualenv] as build I just disable build isolation, this passes the tests, but for actual builds this might fail, so I added a warning that to build for GraalPy on Windows we should use uv until the next GraalPy release.

@timfel
Copy link
Author

timfel commented Apr 4, 2025

Ok, Windows is now green on Azure, not sure why the Linux build got cancelled considering it passed before 🤔

@timfel
Copy link
Author

timfel commented Apr 8, 2025

Thank you @henryiii for fixing the pipeline :) Just to make sure no one is waiting here for us now, is there anything else I should do about this PR right now, or is it fine to just wait for review comments?

@@ -18,6 +18,7 @@ python_configurations = [
{ identifier = "pp39-manylinux_x86_64", version = "3.9", path_str = "/opt/python/pp39-pypy39_pp73" },
{ identifier = "pp310-manylinux_x86_64", version = "3.10", path_str = "/opt/python/pp310-pypy310_pp73" },
{ identifier = "pp311-manylinux_x86_64", version = "3.11", path_str = "/opt/python/pp311-pypy311_pp73" },
{ identifier = "gp242-manylinux_x86_64", version = "3.11", path_str = "/opt/python/graalpy311-graalpy242_311_native" },
Copy link
Contributor

@henryiii henryiii Apr 8, 2025

Choose a reason for hiding this comment

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

Wheels have to be made for each minor version too? I guess this means we can't drop all the workarounds until we drop gp242 (unless there's a patch release planned)?

Copy link
Author

Choose a reason for hiding this comment

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

We are doing patch releases, I missed the merge window for a patch release that goes out next week, but I'm confident I can get the required fixes in for our patch release in June, at which time we can drop this.

Versioning is a bit confusing right now, we used to do calendar versioning with two releases per year, but we are switching to align with the OpenJDK release schedule and will then have 2 releases per year. At that point every 4th release will be a long-term support release, releases in between will only receive support for 6 months. The upcoming release 25 (due out in Sep) will be an LTS, so we could then stick to that for 2 years and also have 26/27/28 each for 6 months until we go to 29 at which point 25 is out of support.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in terms of ABI stability, a sample wheel I just produced was given the filename
spam-0.1.0-graalpy311-graalpy242_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl. So it does look like there's only ABI stability within each minor release of GraalPy (i.e. across patch releases), is that right?

(I just want to check the logic behind this build identifier, as most have the python version at the start, not the interpreter version. But if the ABI stability is tied to the GraalPy minor version, this makes sense to me.)

Copy link
Contributor

@henryiii henryiii left a comment

Choose a reason for hiding this comment

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

This can be batched with other changes if someone else requests changes.

@@ -16,18 +16,19 @@ jobs:
docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all
python -m pip install dependency-groups
python -m dependency_groups test | xargs python -m pip install -e.
python ./bin/run_tests.py
python ./bin/run_tests.py --num-processes 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
python ./bin/run_tests.py --num-processes 2
python ./bin/run_tests.py

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
- bash: |
python -m pip install dependency-groups
python -m dependency_groups test | xargs python -m pip install -e.
python ./bin/run_tests.py --num-processes 2
python ./bin/run_tests.py --num-processes 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
python ./bin/run_tests.py --num-processes 3
python ./bin/run_tests.py

@@ -39,4 +40,4 @@ jobs:
- bash: |
python -m pip install dependency-groups
python -m dependency_groups test | xargs python -m pip install -e.
python ./bin/run_tests.py
python ./bin/run_tests.py --num-processes 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
python ./bin/run_tests.py --num-processes 2
python ./bin/run_tests.py

@@ -18,6 +18,7 @@ python_configurations = [
{ identifier = "pp39-manylinux_x86_64", version = "3.9", path_str = "/opt/python/pp39-pypy39_pp73" },
{ identifier = "pp310-manylinux_x86_64", version = "3.10", path_str = "/opt/python/pp310-pypy310_pp73" },
{ identifier = "pp311-manylinux_x86_64", version = "3.11", path_str = "/opt/python/pp311-pypy311_pp73" },
{ identifier = "gp242-manylinux_x86_64", version = "3.11", path_str = "/opt/python/graalpy311-graalpy242_311_native" },
Copy link
Contributor

Choose a reason for hiding this comment

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

So in terms of ABI stability, a sample wheel I just produced was given the filename
spam-0.1.0-graalpy311-graalpy242_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl. So it does look like there's only ABI stability within each minor release of GraalPy (i.e. across patch releases), is that right?

(I just want to check the logic behind this build identifier, as most have the python version at the start, not the interpreter version. But if the ABI stability is tied to the GraalPy minor version, this makes sense to me.)

Comment on lines -44 to +45
"""python -c "import sys; open('{project}/pythonversion_bb.txt', 'w').write(sys.version)" && """
f'''python -c "import sys; open('{{project}}/pythonprefix_bb.txt', 'w').write({SYS_PREFIX})"'''
"""python -c "import sys; f = open('{project}/pythonversion_bb.txt', 'w'); f.write(sys.version); f.close()" && """
f'''python -c "import sys; f = open('{{project}}/pythonprefix_bb.txt', 'w'); f.write({SYS_PREFIX}); f.close()"'''
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 the reason for this change? I wouldn't expect a problem here given that the Python process is exiting immediately - is the behaviour on GraalPy different?

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