8000 [BUG] `cythonize` does not work on 3.1.0 + gcc 4.8 · Issue #6861 · cython/cython · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[BUG] cythonize does not work on 3.1.0 + gcc 4.8 #6861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oraluben opened this issue May 10, 2025 · 4 comments
Closed

[BUG] cythonize does not work on 3.1.0 + gcc 4.8 #6861

oraluben opened this issue May 10, 2025 · 4 comments

Comments

@oraluben
Copy link
oraluben commented May 10, 2025

Describe the bug

As title.

Example took from https://github.com/pypa/auditwheel/tree/main/tests/integration/sample_extension

git clone https://github.com/pypa/auditwheel.git
cd auditwheel
docker run -v `pwd`:/auditwheel_src -ti quay.io/pypa/manylinux1_x86_64
/opt/_internal/cpython-3.9.19/bin/python -mvenv /venv
source /venv/bin/activate
pip install cython==3.1.0
cd /auditwheel_src/tests/integration/sample_extension/
# This works
cython src/sample_extension.pyx
# This fail
python setup.py develop

Error:

running develop
running egg_info
creating sample_extension.egg-info
writing sample_extension.egg-info/PKG-INFO
writing dependency_links to sample_extension.egg-info/dependency_links.txt
writing top-level names to sample_extension.egg-info/top_level.txt
writing manifest file 'sample_extension.egg-info/SOURCES.txt'
reading manifest file 'sample_extension.egg-info/SOURCES.txt'
writing manifest file 'sample_extension.egg-info/SOURCES.txt'
running build_ext
building 'sample_extension' extension
creating build
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/venv/include -I/opt/_internal/cpython-3.9.19/include/python3.9 -c src/sample_extension.c -o build/temp.linux-x86_64-3.9/src/sample_extension.o
src/sample_extension.c: In function ‘__pyx_pw_16sample_extension_1test_func’:
src/sample_extension.c:2330:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
       for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
       ^
src/sample_extension.c:2330:7: note: use option -std=c99 or -std=gnu99 to compile your code
src/sample_extension.c:2347:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
   ^
src/sample_extension.c:2357:19: error: redefinition of ‘__pyx_temp’
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
                   ^
src/sample_extension.c:2347:19: note: previous definition of ‘__pyx_temp’ was here
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
                   ^
src/sample_extension.c:2357:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
   ^
src/sample_extension.c: In function ‘__Pyx_ParseKeywordsTuple’:
src/sample_extension.c:3972:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
     ^
src/sample_extension.c: In function ‘__Pyx_PyCode_New’:
src/sample_extension.c:6876:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (Py_ssize_t i=0; i < var_count; i++) {
     ^
error: command '/opt/rh/devtoolset-2/root/usr/bin/gcc' failed with exit code 1

Code to reproduce the behaviour:

No response

Expected behaviour

No response

OS

Linux

Python version

3.9.19

Cython version

3.1.0 (3.0.11 works)

Additional context

No response

@scoder
Copy link
Contributor
scoder commented May 10, 2025 via email

@da-woods
Copy link
Contributor

GCC 4.8 looks to support C99. You just have to turn it on with a command line option. So there really isn't any issue here at all

@da-woods da-woods closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2025
@oraluben
Copy link
Author

@da-woods would you mind to show how to enable C99 in setup.py or similar approach? I was imaging cython could detect GCC version and add flag for me.

@da-woods
Copy link
Contributor

It's usually just extra_compile_args=["--std=gnu99"] or something every similar to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0