diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 38c5206d2227..cf2a3d09eb94 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -36,7 +36,7 @@ # It is recommended to import setuptools prior to importing distutils to avoid # using legacy behavior from distutils. # https://setuptools.readthedocs.io/en/latest/history.html#v48-0-0 -from distutils.errors import DistutilsError # isort:skip +from distutils.errors import DistutilsError # isort:skip class mypy(Command): @@ -127,6 +127,7 @@ def get_version(): try: # pylint: disable=wrong-import-position from Cython.Build import cythonize as cythonize0 + def cythonize(*args, **kwargs): import numpy extensions = cythonize0(*args, **kwargs) @@ -142,6 +143,7 @@ def cythonize(*args, **kwargs): else: pyarrow_dependency = 'pyarrow>=3.0.0,<10.0.0' + # We must generate protos after setup_requires are installed. def generate_protos_first(): try: @@ -203,7 +205,6 @@ def get_portability_package_data(): ] }, ext_modules=cythonize([ - # Make sure to use language_level=3 cython directive in files below. 'apache_beam/**/*.pyx', 'apache_beam/coders/coder_impl.py', 'apache_beam/metrics/cells.py', @@ -216,7 +217,7 @@ def get_portability_package_data(): 'apache_beam/transforms/stats.py', 'apache_beam/utils/counters.py', 'apache_beam/utils/windowed_value.py', - ]), + ], language_level=3), install_requires = [ 'crcmod>=1.7,<2.0', 'orjson<4.0',