올해에 Python을 주 기술스택으로 사용하는 회사에 들어갔다보니, Java세계에서 경험하기 어려운 일을 경험하게 됩니다.
이번에 Python 3.10에서 hiredis wheel 빌드 오류를 발견하였습니다.
![](https://blog.kakaocdn.net/dn/bce7JB/btrIT9TzYm7/wbfaK46CLIFiNHlfuY4XbK/img.png)
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/include/openssl11 -I/usr/include/openssl11 -fPIC -Ivendor -I/home/dhsung/.pyenv/versions/3.10.5/envs/tmp-hiredis-build/include -I/home/dhsung/.pyenv/versions/3.10.5/include/python3.10 -c src/hiredis.c -o build/temp.linux-x86_64-cpython-310/src/hiredis.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/include/openssl11 -I/usr/include/openssl11 -fPIC -Ivendor -I/home/dhsung/.pyenv/versions/3.10.5/envs/tmp-hiredis-build/include -I/home/dhsung/.pyenv/versions/3.10.5/include/python3.10 -c src/reader.c -o build/temp.linux-x86_64-cpython-310/src/reader.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/include/openssl11 -I/usr/include/openssl11 -fPIC -Ivendor -I/home/dhsung/.pyenv/versions/3.10.5/envs/tmp-hiredis-build/include -I/home/dhsung/.pyenv/versions/3.10.5/include/python3.10 -c vendor/hiredis/alloc.c -o build/temp.linux-x86_64-cpython-310/vendor/hiredis/alloc.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/include/openssl11 -I/usr/include/openssl11 -fPIC -Ivendor -I/home/dhsung/.pyenv/versions/3.10.5/envs/tmp-hiredis-build/include -I/home/dhsung/.pyenv/versions/3.10.5/include/python3.10 -c vendor/hiredis/read.c -o build/temp.linux-x86_64-cpython-310/vendor/hiredis/read.o
vendor/hiredis/read.c: In function ‘redisReaderFree’:
vendor/hiredis/read.c:646:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < r->tasks; i++) {
^
vendor/hiredis/read.c:646:9: note: use option -std=c99 or -std=gnu99 to compile your code
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: Failed building wheel for hiredis
이 오류는 CentOS7에서 python3.10 버전으로 빌드할때 나오는것으로, 다른 배포판(CentOS 8 Stream, Rocky Linux 8, Ubuntu 20.04, 22.04 LTS)에서는 정상적으로 빌드가 됨을 확인하였습니다.
에러로그를 보고 cpython 3.10용 hiredis wheel이 없나 검색을 하였습니다.
New release for cp3.10 is not on pypi · Issue #121 · redis/hiredis-py
Time for a new release? Btw, travis-ci.org is dead, maybe time to move to github action and cibuildwheel?
github.com
그러나, cpython3.10용 hiredis wheel이 없어서 CentOS7에서 직접 wheel 빌드 어떻게 하나 고민을 했습니다.
에러를 보면 `error: ‘for’ loop initial declarations are only allowed in C99 mode` 메시지가 나옴을 확인하였습니다.
이 에러를 해결을 어떻게 할까 stackoverflow로 검색을 하니 다음의 링크를 발견하였습니다
How to use make and compile as C99?
I'm trying to compile a linux kernel module using a Makefile: obj-m += main.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname...
stackoverflow.com
즉, CentOS7에서 python 3.10용 hiredis 2.0.0 wheel 생성을 하려면 환경변수에 `CFLAGS=-std=c99` 를 추가해야합니다.
환경변수에 `CFLAGS=-std=c99` 를 추가한 결과, cpython3.10용 hiredis wheel 빌드 및 생성 성공하였습니다.
![](https://blog.kakaocdn.net/dn/cFUl3r/btrIO2aj9i7/g8eJmUpoCMy8kAB9zzLFok/img.png)
'컴퓨터 > Python' 카테고리의 다른 글
Python의 우리말 번역은 '파이선', '파이썬', '파이쏜'? (0) | 2020.09.28 |
---|---|
파이썬(Python)에 새로운 애플(Apple) arm64 지원 PR공개 (0) | 2020.06.30 |