ninia / jep

Embed Python in Java
Other
1.28k stars 145 forks source link

‘for’ loop initial declarations are only allowed in C99 mode #445

Closed yangxinyi-bigdata closed 1 year ago

yangxinyi-bigdata commented 1 year ago

Describe the problem I can't successfully install jep in linux environment. It seems that a C99 compilation mode is needed, but it is not. I don't know how to solve this problem. Can you help me? thank you

Environment (please complete the following information):

Logs src/main/c/Objects/pyjtype.c: In function ‘merge_mro’: src/main/c/Objects/pyjtype.c:474:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (Py_ssize_t i = 0; i < n; i++) { ^ src/main/c/Objects/pyjtype.c:474:5: note: use option -std=c99 or -std=gnu99 to compile your code src/main/c/Objects/pyjtype.c: In function ‘pyjtype_mro’: src/main/c/Objects/pyjtype.c:511:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (Py_ssize_t i = 0; i < n; i++) { ^ error: command '/usr/bin/gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> jep

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

Additional context Add any other context about the problem here.

bsteffensmeier commented 1 year ago

I've built jep in a variety of different linux environments and I don't see this problem. If you can provide more information about your environment so I can recreate the problem then we may be able to improve the jep build script to automatically handle this case.

To work around the problem with the current jep build scripts I think you can just export CFLAGS='-std=c99' in the shell before installing jep.

unik00 commented 1 year ago

I've built jep in a variety of different linux environments and I don't see this problem. If you can provide more information about your environment so I can recreate the problem then we may be able to improve the jep build script to automatically handle this case.

I have been able to reproduce the error when installing Jep on Centos 7.

gcc version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44). Python 3.10.8

bsteffensmeier commented 1 year ago

@unik00 Thanks for the extra info, I was able to recreate the problem on a Centos 7 container and have put in a fix (056ce990).

That will be part of the 4.1.1 release in about a month, in the mean time you should be able to build the current version of jep by setting CFLAGS=-std=c99 before building jep.

In general I do not plan to support environments that aren't using at least c99 but the changes in this case are very minor so it will work for the 4.1.1 release.

ndjensen commented 1 year ago

Fixed in 4.1.1.