Skip to content

Commit 8d367d2

Browse files
authoredJan 17, 2025
apacheGH-45237: [Python] Raise minimum supported cython to >=3 (apache#45238)
### Rationale for this change We do not require to support Cython 2 anymore. ### What changes are included in this PR? Bump required version of Cython ### Are these changes tested? Via CI ### Are there any user-facing changes? Yes, pyarrow cannot be compiled with Cython2 anymore. * GitHub Issue: apache#45237 Authored-by: Raúl Cumplido <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent 982c469 commit 8d367d2

18 files changed

+7
-87
lines changed
 

‎.github/workflows/dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
shell: bash
125125
run: |
126126
gem install test-unit
127-
pip install "cython>=0.29.31" setuptools pytest requests setuptools-scm
127+
pip install "cython>=3" setuptools pytest requests setuptools-scm
128128
- name: Run Release Test
129129
env:
130130
ARROW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎ci/conda_env_python.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# don't add pandas here, because it is not a mandatory test dependency
1919
boto3 # not a direct dependency of s3fs, but needed for our s3fs fixture
2020
cffi
21-
cython>=0.29.31
21+
cython>=3
2222
cloudpickle
2323
fsspec
2424
hypothesis

‎ci/docker/conda-python-cython2.dockerfile

-24
This file was deleted.

‎dev/tasks/tasks.yml

-8
Original file line numberDiff line numberDiff line change
@@ -1116,14 +1116,6 @@ tasks:
11161116
PYTHON: "3.10"
11171117
image: conda-python-substrait
11181118

1119-
test-conda-python-3.10-cython2:
1120-
ci: github
1121-
template: docker-tests/github.linux.yml
1122-
params:
1123-
env:
1124-
PYTHON: "3.10"
1125-
image: conda-python-cython2
1126-
11271119
test-ubuntu-22.04-python-313-freethreading:
11281120
ci: github
11291121
template: docker-tests/github.linux.yml

‎docker-compose.yml

-25
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ x-hierarchy:
123123
- conda-python-pandas:
124124
- conda-python-docs
125125
- conda-python-cpython-debug
126-
- conda-python-cython2
127126
- conda-python-dask
128127
- conda-python-emscripten
129128
- conda-python-hdfs
@@ -1495,30 +1494,6 @@ services:
14951494
/arrow/ci/scripts/python_build.sh /arrow /build &&
14961495
/arrow/ci/scripts/integration_substrait.sh"]
14971496

1498-
conda-python-cython2:
1499-
# Usage:
1500-
# docker compose build conda
1501-
# docker compose build conda-cpp
1502-
# docker compose build conda-python
1503-
# docker compose build conda-python-cython2
1504-
# docker compose run --rm conda-python-cython2
1505-
image: ${REPO}:${ARCH}-conda-python-${PYTHON}-cython2
1506-
build:
1507-
context: .
1508-
dockerfile: ci/docker/conda-python-cython2.dockerfile
1509-
cache_from:
1510-
- ${REPO}:${ARCH}-conda-python-${PYTHON}-cython2
1511-
args:
1512-
repo: ${REPO}
1513-
arch: ${ARCH}
1514-
python: ${PYTHON}
1515-
shm_size: *shm-size
1516-
environment:
1517-
<<: [*common, *ccache]
1518-
PYTEST_ARGS: # inherit
1519-
volumes: *conda-volumes
1520-
command: *python-conda-command
1521-
15221497
conda-python-cpython-debug:
15231498
# Usage:
15241499
# docker compose build conda

‎python/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ if(MSVC)
200200
# seem harmless, and probably not worth the effort of working around it
201201
string(APPEND CMAKE_CXX_FLAGS " /wd4800")
202202

203-
# See https://github.com/cython/cython/issues/2731. Change introduced in
204-
# Cython 0.29.1 causes "unsafe use of type 'bool' in operation"
205-
string(APPEND CMAKE_CXX_FLAGS " /wd4804")
206-
207203
# See https://github.com/cython/cython/issues/4445.
208204
#
209205
# Cython 3 emits "(void)__Pyx_PyObject_CallMethod0;" to suppress a

‎python/pyarrow/_azurefs.pyx

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# cython: language_level = 3
1919

20-
from cython cimport binding
21-
2220

2321
from pyarrow.lib import frombytes, tobytes
2422
from pyarrow.includes.libarrow_fs cimport *
@@ -115,7 +113,6 @@ cdef class AzureFileSystem(FileSystem):
115113
self.azurefs = <CAzureFileSystem*> wrapped.get()
116114

117115
@staticmethod
118-
@binding(True) # Required for cython < 3
119116
def _reconstruct(kwargs):
120117
# __reduce__ doesn't allow passing named arguments directly to the
121118
# reconstructor, hence this wrapper.

‎python/pyarrow/_dataset_parquet.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
"""Dataset support for Parquet file format."""
2121

22-
from cython cimport binding
2322
from cython.operator cimport dereference as deref
2423

2524
import os
@@ -890,7 +889,6 @@ cdef class ParquetFragmentScanOptions(FragmentScanOptions):
890889
return attrs == other_attrs
891890

892891
@staticmethod
893-
@binding(True) # Required for Cython < 3
894892
def _reconstruct(kwargs):
895893
# __reduce__ doesn't allow passing named arguments directly to the
896894
# reconstructor, hence this wrapper.

‎python/pyarrow/_fs.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# cython: language_level = 3
1919

2020
from cpython.datetime cimport datetime, PyDateTime_DateTime
21-
from cython cimport binding
2221

2322
from pyarrow.includes.common cimport *
2423
from pyarrow.includes.libarrow_python cimport PyDateTime_to_TimePoint
@@ -422,7 +421,6 @@ cdef class FileSystem(_Weakrefable):
422421
"SubTreeFileSystem")
423422

424423
@staticmethod
425-
@binding(True) # Required for cython < 3
426424
def _from_uri(uri):
427425
fs, _path = FileSystem.from_uri(uri)
428426
return fs

‎python/pyarrow/_gcsfs.pyx

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# cython: language_level = 3
1919

20-
from cython cimport binding
21-
2220
from pyarrow.lib cimport (pyarrow_wrap_metadata,
2321
pyarrow_unwrap_metadata)
2422
from pyarrow.lib import frombytes, tobytes, ensure_metadata
@@ -164,7 +162,6 @@ cdef class GcsFileSystem(FileSystem):
164162
return datetime.fromtimestamp(expiration_ns / 1.0e9, timezone.utc)
165163

166164
@staticmethod
167-
@binding(True) # Required for cython < 3
168165
def _reconstruct(kwargs):
169166
# __reduce__ doesn't allow passing named arguments directly to the
170167
# reconstructor, hence this wrapper.

‎python/pyarrow/_hdfs.pyx

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# cython: language_level = 3
1919

20-
from cython cimport binding
21-
2220
from pyarrow.includes.common cimport *
2321
from pyarrow.includes.libarrow cimport *
2422
from pyarrow.includes.libarrow_fs cimport *
@@ -137,7 +135,6 @@ replication=1)``
137135
return self
138136

139137
@staticmethod
140-
@binding(True) # Required for cython < 3
141138
def _reconstruct(kwargs):
142139
# __reduce__ doesn't allow passing named arguments directly to the
143140
# reconstructor, hence this wrapper.

‎python/pyarrow/_s3fs.pyx

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# cython: language_level = 3
1919

20-
from cython cimport binding
21-
2220
from pyarrow.lib cimport (check_status, pyarrow_wrap_metadata,
2321
pyarrow_unwrap_metadata)
2422
from pyarrow.lib import frombytes, tobytes, KeyValueMetadata
@@ -419,7 +417,6 @@ cdef class S3FileSystem(FileSystem):
419417
self.s3fs = <CS3FileSystem*> wrapped.get()
420418

421419
@staticmethod
422-
@binding(True) # Required for cython < 3
423420
def _reconstruct(kwargs):
424421
# __reduce__ doesn't allow passing named arguments directly to the
425422
# reconstructor, hence this wrapper.

‎python/pyarrow/io.pxi

-1
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,6 @@ cdef class CacheOptions(_Weakrefable):
23702370
ideal_bandwidth_utilization_frac, max_ideal_request_size_mib))
23712371

23722372
@staticmethod
2373-
@binding(True) # Required for Cython < 3
23742373
def _reconstruct(kwargs):
23752374
# __reduce__ doesn't allow passing named arguments directly to the
23762375
# reconstructor, hence this wrapper.

‎python/pyarrow/scalar.pxi

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717

1818
import collections
19-
from cython cimport binding
2019
from uuid import UUID
2120

2221

@@ -895,7 +894,6 @@ cdef class DictionaryScalar(Scalar):
895894
"""
896895

897896
@staticmethod
898-
@binding(True) # Required for cython < 3
899897
def _reconstruct(type, is_valid, index, dictionary):
900898
cdef:
901899
CDictionaryScalarIndexAndDictionary value

‎python/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
[build-system]
1919
requires = [
20-
"cython >= 0.29.31",
20+
"cython >= 3",
2121
# Starting with NumPy 1.25, NumPy is (by default) as far back compatible
2222
# as oldest-support-numpy was (customizable with a NPY_TARGET_VERSION
2323
# define). For older Python versions (where NumPy 1.25 is not yet available)

‎python/requirements-build.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cython>=0.29.31
1+
cython>=3
22
oldest-supported-numpy>=0.14; python_version<'3.9'
33
numpy>=1.25; python_version>='3.9'
44
setuptools_scm>=8

‎python/requirements-wheel-build.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cython>=0.29.31
1+
cython>=3
22
oldest-supported-numpy>=0.14; python_version<'3.9'
33
numpy>=2.0.0; python_version>='3.9'
44
setuptools_scm

‎python/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
)
4949

5050

51-
if Cython.__version__ < '0.29.31':
51+
if Cython.__version__ < '3':
5252
raise Exception(
53-
'Please update your Cython version. Supported Cython >= 0.29.31')
53+
'Please update your Cython version. Supported Cython >= 3')
5454

5555
setup_dir = os.path.abspath(os.path.dirname(__file__))
5656

0 commit comments

Comments
 (0)
Please sign in to comment.