[PYTHON] Error compiling mmh3 module on CircleCI

I got an error when I compiled the mmh3 module, so a memorandum until it was resolved.

  Running setup.py install for murmurhash3
    building 'mmh3' extension
    gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ubuntu/virtualenvs/venv-3.4.1/include -I/home/ubuntu/.pyenv/versions/3.4.1/include/python3.4m -c mmh3module.c -o build/temp.linux-x86_64-3.4/mmh3module.o -std=c99
    mmh3module.c: In function ‘mmh3_hash64’:
    mmh3module.c:63:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
    mmh3module.c: In function ‘mmh3_hash128’:
    mmh3module.c:90:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
    mmh3module.c: In function ‘mmh3_hash_bytes’:
    mmh3module.c:115:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
    mmh3module.c: In function ‘PyInit_mmh3’:
    mmh3module.c:184:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
    cc1: some warnings being treated as errors
    error: command 'gcc' failed with exit status 1
    Complete output from command /home/ubuntu/virtualenvs/venv-3.4.1/bin/python3.4 -c "import setuptools, tokenize;__file__='/home/ubuntu/virtualenvs/venv-3.4.1/build/murmurhash3/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qrmqve3d-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/virtualenvs/venv-3.4.1/include/site/python3.4:
    running install

running build

running build_ext

building 'mmh3' extension

creating build

creating build/temp.linux-x86_64-3.4

gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ubuntu/virtualenvs/venv-3.4.1/include -I/home/ubuntu/.pyenv/versions/3.4.1/include/python3.4m -c mmh3module.c -o build/temp.linux-x86_64-3.4/mmh3module.o -std=c99

mmh3module.c: In function ‘mmh3_hash64’:

mmh3module.c:63:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

mmh3module.c: In function ‘mmh3_hash128’:

mmh3module.c:90:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

mmh3module.c: In function ‘mmh3_hash_bytes’:

mmh3module.c:115:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

mmh3module.c: In function ‘PyInit_mmh3’:

mmh3module.c:184:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

cc1: some warnings being treated as errors

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/ubuntu/virtualenvs/venv-3.4.1/bin/python3.4 -c "import setuptools, tokenize;__file__='/home/ubuntu/virtualenvs/venv-3.4.1/build/murmurhash3/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qrmqve3d-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/virtualenvs/venv-3.4.1/include/site/python3.4 failed with error code 1 in /home/ubuntu/virtualenvs/venv-3.4.1/build/murmurhash3
Storing debug log for failure in /home/ubuntu/.pip/pip.log
((pip install -r "requirements.txt")) returned exit code 1action pip install -r requirements.txt failed

It stops with an error because it has the -Werror = declaration-after-statement option at compile time. I don't want to mess with the source code of the library, and although it's a bit forcible, I overwrote CFLAGS and solved it.

machine:
  environment:
    CFLAGS: -Wno-error=declaration-after-statement

reference

Recommended Posts

Error compiling mmh3 module on CircleCI
Set sitecustomize.py on CircleCI.
Notes on python's sqlite3 module
Install module on Anaconda (Mac)
Error when installing opencv-python on jetson nano (ModuleNotFoundError: No module named'skbuild')