Skip to content

Commit

Permalink
Merge pull request #32112 Upgrade Apache Beam to use Cython 3.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb authored Aug 9, 2024
2 parents 1c0cfa1 + 00de740 commit 49e98e5
Show file tree
Hide file tree
Showing 24 changed files with 9 additions and 41 deletions.
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/coders/coder_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""Coder implementations.
The actual encode/decode implementations are split off from coders to
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/coders/stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""Compiled version of the Stream objects used by CoderImpl.
For internal use only; no backwards-compatibility guarantees.
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""
This file contains metric cell classes. A metric cell is used to accumulate
in-memory changes to a metric. It represents a specific metric in a single
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/metrics/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""
This module is for internal use only; no backwards-compatibility guarantees.
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/metrics/monitoring_infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

# pytype: skip-file

import collections
Expand Down
1 change: 0 additions & 1 deletion sdks/python/apache_beam/runners/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# cython: language_level=3

"""Worker operations executor.
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/runners/worker/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""Python worker logging."""

# pytype: skip-file
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/runners/worker/opcounters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""Counters collect the progress of the Worker for reporting to the service."""

# pytype: skip-file
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/runners/worker/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""Worker operations executor."""

# pytype: skip-file
Expand Down
4 changes: 1 addition & 3 deletions sdks/python/apache_beam/runners/worker/statesampler_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""State sampler for tracking time spent in execution steps.
The state sampler profiles the time spent in each step of a pipeline.
Expand Down Expand Up @@ -59,7 +57,7 @@ cdef extern from "crossplatform_time.h" nogil:
long tv_nsec # nanoseconds
int clock_gettime(int clock_id, timespec *result)

cdef inline int64_t get_nsec_time() nogil:
cdef inline int64_t get_nsec_time() noexcept nogil:
"""Get current time as microseconds since Unix epoch."""
cdef timespec current_time
# First argument value of 0 corresponds to CLOCK_REALTIME.
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/testing/fast_test_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

cimport libc.stdint
cimport libc.stdlib
cimport libc.string
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/transforms/cy_combiners.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""A library of basic cythonized CombineFn subclasses.
For internal use only; no backwards-compatibility guarantees.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# limitations under the License.
#

# cython: language_level=3

""" For internal use only. No backwards compatibility guarantees."""

cimport cython
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/transforms/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
#

# cython: language_level=3

"""This module has all statistic related transforms.
This ApproximateUnique class will be deprecated [1]. PLease look into using
Expand Down
1 change: 0 additions & 1 deletion sdks/python/apache_beam/utils/counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

# cython: profile=False
# cython: overflowcheck=True
# cython: language_level=3

"""Counters collect the progress of the Worker for reporting to the service.
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/apache_beam/utils/windowed_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
# editing this file as WindowedValues are created for every element for
# every step in a Beam pipeline.

# cython: language_level=3

# pytype: skip-file

import collections
Expand Down
4 changes: 1 addition & 3 deletions sdks/python/container/base_image_requirements_manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
# Consider constraining requirements of Beam itself when necessary.

bs4 # Commonly used HTML processing tool.
# Don't upgrade to Cython 3.x, until it's released, stable and we have consensus
# to upgrade. Use 0.xx for now.
cython<1
cython>=3,<4
# future is no longer a Beam dependency, but is an implicit dependency in
# some versions of libraries that launch Beam pipelines, like tensorflow-transform.
# Leaving 'future' in our containers for now prevent breaking tft users.
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/container/py310/base_image_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cloudpickle==2.2.1
cramjam==2.8.3
crcmod==1.7
cryptography==43.0.0
Cython==0.29.37
Cython==3.0.10
deprecation==2.1.0
dill==0.3.1.1
dnspython==2.6.1
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/container/py311/base_image_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cloudpickle==2.2.1
cramjam==2.8.3
crcmod==1.7
cryptography==43.0.0
Cython==0.29.37
Cython==3.0.10
deprecation==2.1.0
dill==0.3.1.1
dnspython==2.6.1
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/container/py312/base_image_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cloudpickle==2.2.1
cramjam==2.8.3
crcmod==1.7
cryptography==43.0.0
Cython==0.29.37
Cython==3.0.10
deprecation==2.1.0
dill==0.3.1.1
dnspython==2.6.1
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/container/py38/base_image_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cloudpickle==2.2.1
cramjam==2.8.3
crcmod==1.7
cryptography==43.0.0
Cython==0.29.37
Cython==3.0.10
deprecation==2.1.0
dill==0.3.1.1
dnspython==2.6.1
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/container/py39/base_image_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cloudpickle==2.2.1
cramjam==2.8.3
crcmod==1.7
cryptography==43.0.0
Cython==0.29.37
Cython==3.0.10
deprecation==2.1.0
dill==0.3.1.1
dnspython==2.6.1
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requires = [
# Numpy headers
"numpy>=1.14.3,<1.27", # Update setup.py as well.
# having cython here will create wheels that are platform dependent.
"cython==0.29.36",
"cython>=3.0,<4",
## deps for generating external transform wrappers:
# also update PyYaml bounds in sdks:python:generateExternalTransformsConfig
'pyyaml>=3.12,<7.0.0',
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_version():
# `pipenv` package managers.
pass

REQUIRED_CYTHON_VERSION = '0.28.1'
REQUIRED_CYTHON_VERSION = '3.0.0'
try:
_CYTHON_VERSION = distribution('cython').version
if parse_version(_CYTHON_VERSION) < parse_version(REQUIRED_CYTHON_VERSION):
Expand Down

0 comments on commit 49e98e5

Please sign in to comment.