Skip to content

Commit 89f90ae

Browse files
Gayathri Srividya RajavarapuGayathri Srividya Rajavarapu
authored andcommitted
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
1 parent 6da06ad commit 89f90ae

1 file changed

Lines changed: 36 additions & 30 deletions

File tree

setup.py

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,46 @@ def make_release_tree(self, base_dir: str, files: list[str]) -> None:
3737

3838

3939
allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1"
40+
# Allow skipping Cython extension build for GCC version compatibility issues (#3259)
41+
skip_cython = os.environ.get("PYICEBERG_SKIP_CYTHON", "0") == "1"
4042

4143
ext_modules = []
4244

43-
try:
44-
import Cython.Compiler.Options
45-
from Cython.Build import cythonize
46-
47-
Cython.Compiler.Options.annotate = True
48-
49-
if os.name == "nt": # Windows
50-
extra_compile_args = ["/O2"]
51-
else: # UNIX-based systems (Linux, macOS)
52-
extra_compile_args = ["-O3"]
53-
54-
package_path = "pyiceberg"
55-
56-
extensions = [
57-
Extension(
58-
"pyiceberg.avro.decoder_fast",
59-
[os.path.join(package_path, "avro", "decoder_fast.pyx")],
60-
extra_compile_args=extra_compile_args,
61-
language="c",
45+
if not skip_cython:
46+
try:
47+
import Cython.Compiler.Options
48+
from Cython.Build import cythonize
49+
50+
Cython.Compiler.Options.annotate = True
51+
52+
if os.name == "nt": # Windows
53+
extra_compile_args = ["/O2"]
54+
else: # UNIX-based systems (Linux, macOS)
55+
extra_compile_args = ["-O3"]
56+
# Suppress warnings that may be treated as errors on newer GCC versions (>= 13.x)
57+
# to ensure compatibility with systems that don't have GCC 12.x (#3259)
58+
extra_compile_args.extend(["-Wno-error=implicit-function-declaration"])
59+
60+
package_path = "pyiceberg"
61+
62+
extensions = [
63+
Extension(
64+
"pyiceberg.avro.decoder_fast",
65+
[os.path.join(package_path, "avro", "decoder_fast.pyx")],
66+
extra_compile_args=extra_compile_args,
67+
language="c",
68+
)
69+
]
70+
71+
ext_modules = cythonize(
72+
extensions,
73+
include_path=[package_path],
74+
compiler_directives={"language_level": "3"},
75+
annotate=True,
6276
)
63-
]
64-
65-
ext_modules = cythonize(
66-
extensions,
67-
include_path=[package_path],
68-
compiler_directives={"language_level": "3"},
69-
annotate=True,
70-
)
71-
except Exception:
72-
if not allowed_to_fail:
73-
raise
77+
except Exception:
78+
if not allowed_to_fail:
79+
raise
7480

7581
pyiceberg_packages = find_packages(include=["pyiceberg*"])
7682
vendor_packages = find_packages(where="vendor", include=["fb303", "hive_metastore"])

0 commit comments

Comments
 (0)