From 89f90aea4ecfa05befbac62daa129f503c386214 Mon Sep 17 00:00:00 2001 From: Gayathri Srividya Rajavarapu Date: Thu, 18 Jun 2026 16:53:56 +0530 Subject: [PATCH] fix: improve GCC version compatibility for C extension builds - Add support for PYICEBERG_SKIP_CYTHON environment variable to allow skipping Cython extension build when compilation fails - Suppress implicit-function-declaration warnings that may occur with GCC 15+ to ensure compatibility with systems that don't have GCC 12.x specifically - Improve build robustness on systems with newer GCC versions while maintaining compatibility with existing versions - Fixes: #3259 --- setup.py | 66 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/setup.py b/setup.py index 34eee94bbd..d54d36a312 100644 --- a/setup.py +++ b/setup.py @@ -37,40 +37,46 @@ def make_release_tree(self, base_dir: str, files: list[str]) -> None: allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1" +# Allow skipping Cython extension build for GCC version compatibility issues (#3259) +skip_cython = os.environ.get("PYICEBERG_SKIP_CYTHON", "0") == "1" ext_modules = [] -try: - import Cython.Compiler.Options - from Cython.Build import cythonize - - Cython.Compiler.Options.annotate = True - - if os.name == "nt": # Windows - extra_compile_args = ["/O2"] - else: # UNIX-based systems (Linux, macOS) - extra_compile_args = ["-O3"] - - package_path = "pyiceberg" - - extensions = [ - Extension( - "pyiceberg.avro.decoder_fast", - [os.path.join(package_path, "avro", "decoder_fast.pyx")], - extra_compile_args=extra_compile_args, - language="c", +if not skip_cython: + try: + import Cython.Compiler.Options + from Cython.Build import cythonize + + Cython.Compiler.Options.annotate = True + + if os.name == "nt": # Windows + extra_compile_args = ["/O2"] + else: # UNIX-based systems (Linux, macOS) + extra_compile_args = ["-O3"] + # Suppress warnings that may be treated as errors on newer GCC versions (>= 13.x) + # to ensure compatibility with systems that don't have GCC 12.x (#3259) + extra_compile_args.extend(["-Wno-error=implicit-function-declaration"]) + + package_path = "pyiceberg" + + extensions = [ + Extension( + "pyiceberg.avro.decoder_fast", + [os.path.join(package_path, "avro", "decoder_fast.pyx")], + extra_compile_args=extra_compile_args, + language="c", + ) + ] + + ext_modules = cythonize( + extensions, + include_path=[package_path], + compiler_directives={"language_level": "3"}, + annotate=True, ) - ] - - ext_modules = cythonize( - extensions, - include_path=[package_path], - compiler_directives={"language_level": "3"}, - annotate=True, - ) -except Exception: - if not allowed_to_fail: - raise + except Exception: + if not allowed_to_fail: + raise pyiceberg_packages = find_packages(include=["pyiceberg*"]) vendor_packages = find_packages(where="vendor", include=["fb303", "hive_metastore"])