Skip to content

GH-47256: [Python] Do not use cffi in free-threaded 3.13 builds - #47313

Merged
AlenkaF merged 8 commits into
apache:mainfrom
AlenkaF:fix-windows-builds
Sep 2, 2025
Merged

GH-47256: [Python] Do not use cffi in free-threaded 3.13 builds#47313
AlenkaF merged 8 commits into
apache:mainfrom
AlenkaF:fix-windows-builds

Conversation

@AlenkaF

@AlenkaFAlenkaF commented Aug 12, 2025

Copy link
Copy Markdown
Member

Rationale for this change

Ubuntu and Windows wheels started failing on free-threaded build of CPython 3.13 due to cffi not supporting free-threaded CPython 3.13.

What changes are included in this PR?

Free-threaded 3.13 builds use separate requirements with no cffi.

Are these changes tested?

Yes, with the extended builds.

Are there any user-facing changes?

No.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47256has been automatically assigned in GitHub to PR creator.

@github-actionsgithub-actionsBot added the awaiting review Awaiting review label Aug 12, 2025
@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-cp313-cp313t-amd64

@github-actions

Copy link
Copy Markdown

Revision: fcd62fe215030e748ae65def07e68ebea69b6035

Submitted crossbow builds: ursacomputing/crossbow @ actions-4c2b829fab

TaskStatus
wheel-windows-cp313-cp313t-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit test-ubuntu-22.04-python-313-freethreading

@github-actions

Copy link
Copy Markdown

Revision: fcd62fe215030e748ae65def07e68ebea69b6035

Submitted crossbow builds: ursacomputing/crossbow @ actions-860e036ce5

TaskStatus
test-ubuntu-22.04-python-313-freethreadingGitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

Installing cffi again with a pinned version won't help, as the first install from requirements-*-test.txt already triggers the failure.

Pinning cffi globally isn’t ideal since this only affects the 3.13 free-threaded build.

Instead, we can patch the requirements file directly in the Dockerfile to exclude cffi and re-add it with a pinned version (<2.0.0). This avoids maintaining a separate override file and keeps the change localized to the affected build.

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit test-ubuntu-22.04-python-313-freethreading

@github-actions

Copy link
Copy Markdown

Revision: d853ccc9ba0371906bec98d56e2641a16f955199

Submitted crossbow builds: ursacomputing/crossbow @ actions-5fc39b3bfa

TaskStatus
test-ubuntu-22.04-python-313-freethreadingGitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-cp313-cp313t-amd64

@github-actions

Copy link
Copy Markdown

Revision: d853ccc9ba0371906bec98d56e2641a16f955199

Submitted crossbow builds: ursacomputing/crossbow @ actions-2685669349

TaskStatus
wheel-windows-cp313-cp313t-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

The last commit fixes the build failures related to cffi and the CPython 3.13 version discrepancy.

I’m not sure if patching in the Dockerfile is the best approach, so I’m happy to change it if needed—cc @kou.

Now that the cffi failure is resolved, I’m continuing to investigate the Windows Cython failures (see #47308). If I find a fix, I might add it here in the same PR.

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-*

@github-actions

Copy link
Copy Markdown

Revision: cc758f4d36e3fdc48c96a85bc82a77b1bbf0d15e

Submitted crossbow builds: ursacomputing/crossbow @ actions-3c0c8c4c06

TaskStatus
wheel-windows-cp310-cp310-amd64GitHub Actions
wheel-windows-cp311-cp311-amd64GitHub Actions
wheel-windows-cp312-cp312-amd64GitHub Actions
wheel-windows-cp313-cp313-amd64GitHub Actions
wheel-windows-cp313-cp313t-amd64GitHub Actions
wheel-windows-cp39-cp39-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

Ah, I need to fix the Windows patch issue. Didn't saw that before: https://github.com/ursacomputing/crossbow/actions/runs/16905769938/job/47895087244#step:9:504

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-*

@AlenkaFAlenkaF changed the title GH-47256: [Python] Pin cffi in free-threaded buildsGH-47256: [Python] Pin cffi in free-threaded builds and use newer Win SDKAug 12, 2025
@AlenkaFAlenkaF changed the title GH-47256: [Python] Pin cffi in free-threaded builds and use newer Win SDKGH-47256: [Python] Pin cffi in free-threaded builds and use newer Win SDK in Windows wheelsAug 12, 2025
@github-actions

Copy link
Copy Markdown

Revision: caa7067a6fa956364bc905b0c3d185c205c603bd

Submitted crossbow builds: ursacomputing/crossbow @ actions-02fe533f65

TaskStatus
wheel-windows-cp310-cp310-amd64GitHub Actions
wheel-windows-cp311-cp311-amd64GitHub Actions
wheel-windows-cp312-cp312-amd64GitHub Actions
wheel-windows-cp313-cp313-amd64GitHub Actions
wheel-windows-cp313-cp313t-amd64GitHub Actions
wheel-windows-cp39-cp39-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-cp310-cp310-amd64

@github-actions

Copy link
Copy Markdown

Revision: 55dc4acfcb1f9decc6921276295ce745a90f03cf

Submitted crossbow builds: ursacomputing/crossbow @ actions-b37f110292

TaskStatus
wheel-windows-cp310-cp310-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-cp310-cp310-amd64

@github-actions

Copy link
Copy Markdown

Revision: d9e53fd1786daf7a085c2054252c23b27c8b9d75

Submitted crossbow builds: ursacomputing/crossbow @ actions-1131ef4771

TaskStatus
wheel-windows-cp310-cp310-amd64GitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit wheel-windows-cp310-cp310-amd64

@github-actions

Copy link
Copy Markdown

Revision: 4228c421ce036d96ea2eb947ec2dff1c1ddefac3

Submitted crossbow builds: ursacomputing/crossbow @ actions-bee8b2d046

TaskStatus
wheel-windows-cp310-cp310-amd64GitHub Actions

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.

Can we use Environment Markers https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers instead of this approach? Something like:

--- a/python/requirements-test.txt+++ b/python/requirements-test.txt@@ -1,4 +1,5 @@-cffi+cffi; python_version != '3.13t'+cffi<2.0.0; python_version == '3.13t'
hypothesis
packaging
pandas

(I'm not sure whether we have a variable to determine free-threaded CPython...)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Oh, that is much much nicer! Thank you @kou .
I noticed a use of PYTHON_GIL in the free-threaded builds. Looking at python-wheels/github.osx.yml it seems same as what you suggested in this diff.

@AlenkaFAlenkaFAug 13, 2025

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Unfortunately, python_version doesn't support detailed versions like 3.13t — it only handles the major.minor format:

Ignoring cffi: markers 'python_version == "3.13t"' don't match your environment

See: https://github.com/ursacomputing/crossbow/actions/runs/16930331373/job/47974180274#step:6:722

Other markers listed in PEP 508 don't help either.
Using something like os.environ.get("PYTHON_GIL") in a requirements file is also ignored by pip, since arbitrary Python expressions aren’t supported in markers.

Not sure about other options — will keep investigating.

@WillAydWillAydAug 15, 2025

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.

That's surprising that it only handles major and minor versions. I think the docs even show examples with a patch version?

https://packaging.python.org/en/latest/specifications/dependency-specifiers/#specification

I wonder if including a patch number here would be helpful? I'm not sure that Python's packaging story is complete around the t suffix and how version comparisons are handled (my knowledge could also be outdated!)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It is surprising, yeah. In the examples shared patch versions are not used in the python_version Environment Marker. For example, this issue led me to believe that python_version only considers the major and minor versions.

As for the t suffix, I’m also not entirely sure about the background there. I vaguely remember hearing at EuroPython that it's going to stay, but I could be misremembering 😬

@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Aug 12, 2025
@github-actionsgithub-actionsBot added the awaiting changes Awaiting changes label Aug 27, 2025
# version. However, there is no need to make this strictly the oldest version,
# so it can be broadened to have a single version specification across platforms.
# (`~=x.y.z` specifies a compatible release as `>=x.y.z, == x.y.*`)
numpy~=1.21.3; python_version < "3.11"

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.

Since this file is for 3.13, these lines can be simplified :)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Oh yes! Will do.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Done: 430f26b

@pitrou

Copy link
Copy Markdown
Member

@AlenkaF Can you update the PR title to reflect the PR contents?

@AlenkaFAlenkaF changed the title GH-47256: [Python] Pin cffi in free-threaded buildsGH-47256: [Python] Do not use cffi in free-threaded 3.13 buildsAug 27, 2025
@github-actionsgithub-actionsBot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Sep 1, 2025
@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit test-ubuntu-22.04-python-313-freethreading

@github-actions

Copy link
Copy Markdown

Revision: 430f26b

Submitted crossbow builds: ursacomputing/crossbow @ actions-c0a94d79aa

TaskStatus
test-ubuntu-22.04-python-313-freethreadingGitHub Actions

@raulcd

Copy link
Copy Markdown
Member

@github-actions crossbow submit test-ubuntu-22.04-python-313-freethreading

@github-actions

Copy link
Copy Markdown

Revision: c5c8e4e

Submitted crossbow builds: ursacomputing/crossbow @ actions-ac6d583157

TaskStatus
test-ubuntu-22.04-python-313-freethreadingGitHub Actions

@AlenkaF

Copy link
Copy Markdown
MemberAuthor

Should we wait for the Windows wheels issue to be fixed so we can test the changes on wheel-windows-cp313-cp313t-amd64 also?

@raulcd

Copy link
Copy Markdown
Member

Should we wait for the Windows wheels issue to be fixed so we can test the changes on wheel-windows-cp313-cp313t-amd64 also?

I don't think we should, the Windows wheel issue is currently "blocked" by vcpkg issues and not being able to properly diagnose due to the lack of logs from vcpkg.

@raulcdraulcd 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.

LGTM

@github-actionsgithub-actionsBot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Sep 2, 2025
@AlenkaF

Copy link
Copy Markdown
MemberAuthor

@pitrou mind having one last look before we merge?

@pitroupitrou 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.

This LGTM, thank you.

In the future, we might want to replace this with a requirements-test-free-threaded.txt...

@AlenkaF
AlenkaF merged commit 55be8c0 into apache:mainSep 2, 2025
34 of 36 checks passed
@AlenkaFAlenkaF removed the awaiting merge Awaiting merge label Sep 2, 2025
@AlenkaF
AlenkaF deleted the fix-windows-builds branch September 2, 2025 07:56
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 55be8c0.

There weren't enough matching historic benchmark results to make a call on whether there were regressions.

The full Conbench report has more details.

@ngoldbaum

Copy link
Copy Markdown

Sorry the explicit lack of support for 3.13t in CFFI 2.0.0 caused you all a little headache here. Glad it was all sorted out eventually.

@AlenkaF

AlenkaF commented Sep 15, 2025

Copy link
Copy Markdown
MemberAuthor

No worries at all, just a minor PR needed. Thanks for all the work on your side @ngoldbaum !

Mottl pushed a commit to Mottl/arrow that referenced this pull request May 26, 2026
…apache#47313)
### Rationale for this change
Ubuntu and Windows wheels started failing on free-threaded build of CPython 3.13 due to cffi not supporting free-threaded CPython 3.13.
### What changes are included in this PR?
Free-threaded 3.13 builds use separate requirements with no cffi.
### Are these changes tested?
Yes, with the extended builds.
### Are there any user-facing changes?
No.
* GitHub Issue: apache#47256
Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
Sign up for freeto 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.

6 participants

@AlenkaF@pitrou@raulcd@ngoldbaum@kou@WillAyd