pip install tablesでerror: implicit declaration of function 'H5close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

こんなエラーが出る。hdf5が無いらしい。

$ pip install tables
Collecting tables
  Using cached tables-3.6.1.tar.gz (4.6 MB)
    ERROR: Command errored out with exit status 1:
     command: /Users/taisyo/.pyenv/versions/3.9-dev/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-ovh_8boi/tables/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-ovh_8boi/tables/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-pip-egg-info-n71yibiu
         cwd: /private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-ovh_8boi/tables/
    Complete output (11 lines):
    /var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/H5closee3bba902.c:2:5: error: implicit declaration of function 'H5close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        H5close();
        ^
    1 error generated.
    cpuinfo failed, assuming no CPU features: py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.
    * Using Python 3.9.2+ (heads/3.9:2c0a0b0, Mar  8 2021, 14:56:53)
    * USE_PKGCONFIG: True
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

hdf5を入れる。

$ brew install hdf5
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 1 cask.

==> Downloading https://homebrew.bintray.com/bottles/hdf5-1.12.0_1.arm64_big_sur.bottle.1.tar.gz
Already downloaded: /Users/taisyo/Library/Caches/Homebrew/downloads/2519c56431b045efadebccfd6f8ca4fc45e82ef450ba91f825d9746f7f0b8c05--hdf5-1.12.0_1.arm64_big_sur.bottle.1.tar.gz
==> Pouring hdf5-1.12.0_1.arm64_big_sur.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/hdf5/1.12.0_1: 268 files, 19.4MB

再度試してみるが、hd5を見つけられないようだ。

$ pip install tables
Collecting tables
  Using cached tables-3.6.1.tar.gz (4.6 MB)
    ERROR: Command errored out with exit status 1:
     command: /Users/taisyo/.pyenv/versions/3.9-dev/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-n07_epor/tables/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-n07_epor/tables/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-pip-egg-info-l0st9pe_
         cwd: /private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-n07_epor/tables/
    Complete output (11 lines):
    /var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/H5close7arid9o4.c:2:5: error: implicit declaration of function 'H5close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        H5close();
        ^
    1 error generated.
    cpuinfo failed, assuming no CPU features: py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.
    * Using Python 3.9.2+ (heads/3.9:2c0a0b0, Mar  8 2021, 14:56:53)
    * USE_PKGCONFIG: True
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

hdf5を指定してみるが、lseekが見つけられないらしい。

$ HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_1/ pip install tables
c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:256:24: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            state->start = LSEEK(state->fd, 0, SEEK_CUR);
                           ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:256:24: note: did you mean 'fseek'?
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:162:6: note: 'fseek' declared here
    int      fseek(FILE *, long, int);
             ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:355:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
            ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:396:15: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
                  ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:492:14: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        offset = LSEEK(state->fd, 0, SEEK_CUR);
                 ^
    c-blosc/internal-complibs/zlib-1.2.8/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    4 errors generated.
    error: command '/usr/bin/clang' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/taisyo/.pyenv/versions/3.9-dev/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-__cbmmuq/tables/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-install-__cbmmuq/tables/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/tn25979s7fd82bkj_tj6hd0r0000gn/T/pip-record-zl9x2spz/install-record.txt --single-version-externally-managed --compile --install-headers /Users/taisyo/.pyenv/versions/3.9-dev/include/python3.9/tables Check the logs for full command output.

無いわけがないので、-Wnoしてみる。

$ HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_1/ CFLAGS=-Wno-implicit-function-declaration pip install tables
Collecting tables
  Using cached tables-3.6.1.tar.gz (4.6 MB)
Requirement already satisfied: numpy>=1.9.3 in /Users/taisyo/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from tables) (1.20.1)
Requirement already satisfied: numexpr>=2.6.2 in /Users/taisyo/.pyenv/versions/3.9-dev/lib/python3.9/site-packages (from tables) (2.7.3)
Using legacy 'setup.py install' for tables, since package 'wheel' is not installed.
Installing collected packages: tables
    Running setup.py install for tables ... done
Successfully installed tables-3.6.1

入った。