Skip to content

GH-41475: [Python] Build with Python 3.13 - #42034

Merged
raulcd merged 3 commits into
apache:mainfrom
tacaswell:fix/py313
Jun 26, 2024
Merged

GH-41475: [Python] Build with Python 3.13#42034
raulcd merged 3 commits into
apache:mainfrom
tacaswell:fix/py313

Conversation

@tacaswell

@tacaswelltacaswell commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

Rationale for this change

The private function _Py_IsFinalizing renamed to Py_IsFinalizing in Python 3.13.0a1. Without this change pyarrow will not compile with this version of Python or higher.

What changes are included in this PR?

add a version-gated #define to handle the change.

Are these changes tested?

Local build succeeds.

Are there any user-facing changes?

no

@github-actions

Copy link
Copy Markdown

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

@koukou changed the title GH-41475: [PYTHON] build with py313GH-41475: [Python] Build with py313Jun 8, 2024
@kou
kou requested a review from pitrouJune 8, 2024 20:13
Comment threadpython/pyarrow/src/arrow/python/udf.cc Outdated
@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jun 8, 2024
@pitrou

Copy link
Copy Markdown
Member

Instead of doing such adjustements one by one, how about we vendor a version of https://github.com/python/pythoncapi-compat ? cc @jorisvandenbossche

@github-actionsgithub-actionsBot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jun 10, 2024
tacaswelland others added 2 commits June 10, 2024 13:42
The private function `_Py_IsFinalizing` renamed to `Py_IsFinalizing` in Python
3.13.0a1
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@jorisvandenbossche

Copy link
Copy Markdown
Member

Instead of doing such adjustements one by one, how about we vendor a version of https://github.com/python/pythoncapi-compat ?

I am not very familiar with it to estimate how much we would make use of it (this PR also essentially only adds 3 lines, and the actual changes to change _Py_IsFinalizing to Py_IsFinalizing is still something that we would had to do). But yes, if that tool is exactly meant for this, maybe why not just use it.

I quickly tested its upgrade script on the pyarrow C++ code, and what it does change is replace a bunch of .. == Py_None cases with Py_IsNone(..).

But maybe the more interesting usage of the tool would be that we can use newer C API functions in our code that might make our PyArrow C++ easier to read or maintain? (but again not sure how much of those cases would actually apply here)

Comment threadpython/pyarrow/src/arrow/python/udf.cc
@jorisvandenbossche

Copy link
Copy Markdown
Member

(I am also fine with considering https://github.com/python/pythoncapi-compat for a follow-up issue, and at least ensure now pyarrow builds with Python 3.13)

@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Jun 11, 2024
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@github-actionsgithub-actionsBot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jun 11, 2024
@pitrou

Copy link
Copy Markdown
Member

I quickly tested its upgrade script on the pyarrow C++ code, and what it does change is replace a bunch of .. == Py_None cases with Py_IsNone(..).

But maybe the more interesting usage of the tool would be that we can use newer C API functions in our code that might make our PyArrow C++ easier to read or maintain? (but again not sure how much of those cases would actually apply here)

Yes, the idea would be to use newer C API functions as in this PR. Vendoring it should be trivial: there is a single .h file.

@jorisvandenbosschejorisvandenbossche changed the title GH-41475: [Python] Build with py313GH-41475: [Python] Build with Python 3.13Jun 19, 2024
@jorisvandenbossche

Copy link
Copy Markdown
Member

I don't have time this or coming week to look into vendoring pythoncapi-compat, ad given the upcoming feature freeze for 17.0 the week after, I would suggest we merge this for now and track using pythoncapi-compat as a follow-up issue.

@jorisvandenbosschejorisvandenbossche added this to the 17.0.0 milestone Jun 20, 2024
kou
kou approved these changes Jun 20, 2024

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

+1

@github-actionsgithub-actionsBot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Jun 20, 2024
@raulcd

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g python

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

I am running extra CI for this. If tests are successful I'll merge as is and we can open a follow up issue to vendor pythoncapi-compat as suggested

@github-actions

Copy link
Copy Markdown

Revision: 79c37cd

Submitted crossbow builds: ursacomputing/crossbow @ actions-d83aa38dd0

TaskStatus
example-python-minimal-build-fedora-condaGitHub Actions
example-python-minimal-build-ubuntu-venvGitHub Actions
test-conda-python-3.10GitHub Actions
test-conda-python-3.10-cython2GitHub Actions
test-conda-python-3.10-hdfs-2.9.2GitHub Actions
test-conda-python-3.10-hdfs-3.2.1GitHub Actions
test-conda-python-3.10-pandas-latestGitHub Actions
test-conda-python-3.10-pandas-nightlyGitHub Actions
test-conda-python-3.10-spark-v3.5.0GitHub Actions
test-conda-python-3.10-substraitGitHub Actions
test-conda-python-3.11GitHub Actions
test-conda-python-3.11-dask-latestGitHub Actions
test-conda-python-3.11-dask-upstream_develGitHub Actions
test-conda-python-3.11-hypothesisGitHub Actions
test-conda-python-3.11-pandas-upstream_develGitHub Actions
test-conda-python-3.11-spark-masterGitHub Actions
test-conda-python-3.12GitHub Actions
test-conda-python-3.8GitHub Actions
test-conda-python-3.8-pandas-1.0GitHub Actions
test-conda-python-3.8-spark-v3.5.0GitHub Actions
test-conda-python-3.9GitHub Actions
test-conda-python-3.9-pandas-latestGitHub Actions
test-cuda-pythonGitHub Actions
test-debian-12-python-3-amd64GitHub Actions
test-debian-12-python-3-i386GitHub Actions
test-fedora-39-python-3GitHub Actions
test-ubuntu-20.04-python-3GitHub Actions
test-ubuntu-22.04-python-3GitHub Actions

@raulcd

Copy link
Copy Markdown
Member

Failures are unrelated

@raulcd

Copy link
Copy Markdown
Member

I've created the follow up issue #43069 to vendor https://github.com/python/pythoncapi-compat

@tacaswell
tacaswell deleted the fix/py313 branch June 26, 2024 21:01
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 1ce69ec.

There were 12 benchmark results with an error:

There was 1 benchmark result indicating a performance regression:

The full Conbench report has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them.

jorisvandenbossche added a commit that referenced this pull request Aug 21, 2024
### Rationale for this change
#43540 already vendored `pythoncapi_compat.h`, so closing #43069 by using this as well for `Py_IsFinalizing` (which was added in #42034, and for which we opened that follow-up issue to use `pythoncapi_compat.h` instead)
Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
QuietCraftsmanship pushed a commit to QuietCraftsmanship/arrow that referenced this pull request Jul 7, 2025
### Rationale for this change
apache/arrow#43540 already vendored `pythoncapi_compat.h`, so closing apache/arrow#43069 by using this as well for `Py_IsFinalizing` (which was added in apache/arrow#42034, and for which we opened that follow-up issue to use `pythoncapi_compat.h` instead)
Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@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.

5 participants

@tacaswell@pitrou@jorisvandenbossche@raulcd@kou