hack のためのネタ帳, etc,,,

状況

pip3 で入れてみると DLL を拾えずインストールが途中で止まる。
$ pip3 install h5py
Collecting h5py
  Using cached https://files.pythonhosted.org/packages/5f/97/a58afbcf40e8abecededd9512978b4e4915374e5b80049af082f49cebe9a/h5py-2.10.0.tar.gz
Requirement already satisfied: numpy>=1.7 in /usr/lib/python3.6/site-packages (from h5py) (1.16.2)
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from h5py) (1.12.0)
Installing collected packages: h5py
  Running setup.py install for h5py ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m6g99q0i/h5py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m6g99q0i/h5py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xwxv9bou/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-m6g99q0i/h5py/
    Complete output (88 lines):
    Unable to find pgen, not compiling formal grammar.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Plex/Scanners.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Plex/Actions.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/Scanning.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/Visitor.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/FlowControl.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Runtime/refnanny.pyx because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/FusedNode.py because it changed.
    Compiling /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Tempita/_tempita.py because it changed.
    [1/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/FlowControl.py
    [2/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/FusedNode.py
    [3/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/Scanning.py
    [4/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Compiler/Visitor.py
    [5/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Plex/Actions.py
    [6/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Plex/Scanners.py
    [7/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Runtime/refnanny.pyx
    [8/8] Cythonizing /tmp/easy_install-g8sgu62_/Cython-0.29.14/Cython/Tempita/_tempita.py
    warning: no files found matching 'Doc/*'
    warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
    warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
    warning: no files found matching '*.pxd' under directory 'Cython/Utility'
    warning: no files found matching 'pyximport/README'

    Installed /tmp/pip-install-m6g99q0i/h5py/.eggs/Cython-0.29.14-py3.6-cygwin-3.1.2-x86_64.egg
    running install
    running build
    running build_py
    creating build
    creating build/lib.cygwin-3.1.2-x86_64-3.6
    creating build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    copying h5py/h5py_warnings.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    copying h5py/highlevel.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    copying h5py/ipy_completer.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    copying h5py/version.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    copying h5py/__init__.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py
    creating build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/attrs.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/base.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/compat.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/dataset.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/datatype.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/dims.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/files.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/filters.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/group.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/selections.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/selections2.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/vds.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    copying h5py/_hl/__init__.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/_hl
    creating build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/common.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_attribute_create.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_attrs.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_attrs_data.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_base.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_completions.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dataset.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dataset_getitem.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dataset_swmr.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_datatype.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_deprecation.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dimension_scales.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dims_dimensionproxy.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_dtype.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_file.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_file2.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_file_image.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_filters.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_group.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5d_direct_chunk.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5f.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5p.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5pl.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_h5t.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_objects.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_selections.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_slicing.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/test_threads.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    copying h5py/tests/__init__.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests
    creating build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests/test_vds
    copying h5py/tests/test_vds/test_highlevel_vds.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests/test_vds
    copying h5py/tests/test_vds/test_lowlevel_vds.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests/test_vds
    copying h5py/tests/test_vds/test_virtual_source.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests/test_vds
    copying h5py/tests/test_vds/__init__.py -> build/lib.cygwin-3.1.2-x86_64-3.6/h5py/tests/test_vds
    running build_ext
    Loading library to get version: hdf5.dll
    error: No such file or directory
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m6g99q0i/h5py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m6g99q0i/h5py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xwxv9bou/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

いい加減な解決策

間に合わせとしては、とりあえず、cyghdf5-103.dll への symbolic link として hdf5.dll を作っておけばよい。
cd /bin
ln -s cyghdf5-103.dll hdf5.dll

まじめな解決策

未解決案件

h5py 2.10.0 で問題の箇所は多分以下
一方、Cygwin のファイルの状況は以下の通り。
$ ls /bin/*hdf5*
/bin/cyghdf5_cpp-102.dll     /bin/cyghdf5_hl-10.dll   /bin/cyghdf5-101.dll
/bin/cyghdf5_cpp-103.dll     /bin/cyghdf5_hl-100.dll  /bin/cyghdf5-103.dll
/bin/cyghdf5_hl_cpp-100.dll  /bin/cyghdf5-10.dll

まず、default_path が 'hdf5.dll' なのと regexp が r'^hdf5.dll' なんだけどどっちにもマッチしない。
正しくは regexp = re.compile(r'^(cyg)?hdf5(-\d+)?.dll')

更に、libdirs から探そうとしているけど、cygwin の dll は bindirs に入ってるので、そっちを探す必要がある。
ただしこれは、/bin/hdf5.dll があれば解決出来ているので、多分探しているんだと思う。

参考になりそうな実装としては、netcdf4-python に以下の部分が見つかった。
あと、 は微妙に問題で、これは、UNIX 系で libhdf5.so.1.10.6 等の推奨バージョンが libhdf5.so に symbolic link されていることをになっているようなのだが、
cygwin だと cyghdf5-10.dll, cyghdf5-101.dll, cyghdf5-103.dll のうち、一番バージョンの古い cyghdf5-10.dll が選択されてしまうだろう。
多分、推奨は 1.10.6 の cyghdf5-103.dll なので、これは困るのだが、UNIX 系と齟齬のないシンプルな方法が思い浮かばん。
Cygwin だけ別に条件分岐したほうが吉か?

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます