bdist_wheel无法在MSYS2

时间:2016-07-19 03:20:56

标签: python python-wheel msys2

我正在尝试使用Windows 7 VirtualBox VM上的MSYS2 MINGW64 shell构建Python包。该软件包在Linux上成功构建,安装和导入。

我可以在MSYS2下构建一个二进制轮...

$ python setup.py bdist_wheel
running bdist_wheel
running build
running build_py
running build_ext
running build_scripts
installing to build/bdist.mingw/wheel
running install
running install_lib
running install_egg_info
running egg_info
writing stencila.egg-info/PKG-INFO
writing top-level names to stencila.egg-info/top_level.txt
writing dependency_links to stencila.egg-info/dependency_links.txt
reading manifest file 'stencila.egg-info/SOURCES.txt'
writing manifest file 'stencila.egg-info/SOURCES.txt'
Copying stencila.egg-info to /build/bdist.mingw/wheel/./stencila-0.24.0+a67987b-py2.7.egg-info
running install_scripts
creating build/bdist.mingw/wheel/stencila-0.24.0+a67987b.dist-info/WHEEL

但实际上是“空”(缺少已编译的C ++扩展和Python源代码)......

$ unzip -l dist/stencila-0.24.0+a67987b-cp27-cp27m-mingw.whl
Archive:  dist/stencila-0.24.0+a67987b-cp27-cp27m-mingw.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
       10  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/DESCRIPTION.rst
      398  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/metadata.json
        9  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/top_level.txt
      102  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/WHEEL
      235  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/METADATA
      550  2016-07-19 02:47   stencila-0.24.0+a67987b.dist-info/RECORD
---------                     -------
     1304                     6 files

所以虽然它会安装,但无法导入......

$ pip install --upgrade dist/stencila-0.24.0+a67987b-cp27-cp27m-mingw.whl
Processing c:/stencila/py/dist/stencila-0.24.0+a67987b-cp27-cp27m-mingw.whl
Installing collected packages: stencila
  Found existing installation: stencila 0.24.0+5a660f0
    Uninstalling stencila-0.24.0+5a660f0:
      Successfully uninstalled stencila-0.24.0+5a660f0
Successfully installed stencila-0.24.0+a67987b
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

$ python -c "import stencila"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named stencila

我在Appveyor上得到了同样的行为。

相比之下,使用python setup.py bdist_egg构建的二元蛋中包含了所有内容......

$ unzip -l dist/stencila-0.24.0+a67987b-py2.7-mingw.egg
Archive:  dist/stencila-0.24.0+a67987b-py2.7-mingw.egg
  Length      Date    Time    Name
---------  ---------- -----   ----
        1  2016-07-19 14:47   EGG-INFO/dependency_links.txt
       24  2016-07-19 14:47   EGG-INFO/native_libs.txt
      242  2016-07-19 14:47   EGG-INFO/PKG-INFO
      403  2016-07-19 14:47   EGG-INFO/SOURCES.txt
        9  2016-07-19 14:47   EGG-INFO/top_level.txt
        2  2016-07-19 14:47   EGG-INFO/zip-safe
     3465  2016-07-19 14:44   EGG-INFO/scripts/stencila-py
     1747  2016-07-04 13:29   stencila/component.py
     1564  2016-07-19 14:47   stencila/component.pyc
     7224  2016-07-04 13:29   stencila/context.py
     8061  2016-07-19 14:47   stencila/context.pyc
      293  2016-07-19 14:47   stencila/extension.py
      538  2016-07-19 14:47   stencila/extension.pyc
  4146176  2016-07-19 14:44   stencila/extension.pyd
      880  2016-07-04 13:29   stencila/sheet.py
     1472  2016-07-19 14:47   stencila/sheet.pyc
     3251  2016-07-04 13:29   stencila/spread.py
     4699  2016-07-19 14:47   stencila/spread.pyc
     1092  2016-07-04 13:29   stencila/stencil.py
     1690  2016-07-19 14:47   stencila/stencil.pyc
      376  2016-07-04 13:29   stencila/__init__.py
      528  2016-07-19 14:47   stencila/__init__.pyc
---------                     -------
  4183737                     22 files

按预期安装和导入......

$ easy_install dist/stencila-0.24.0+a67987b-py2.7-mingw.egg
Processing stencila-0.24.0+a67987b-py2.7-mingw.egg
Copying stencila-0.24.0+a67987b-py2.7-mingw.egg to c:/msys64/mingw64/lib/python2.7/site-packages
Adding stencila 0.24.0+a67987b to easy-install.pth file
Installing stencila-py script to C:/msys64/mingw64/bin

Installed c:/msys64/mingw64/lib/python2.7/site-packages/stencila-0.24.0+a67987b-py2.7-mingw.egg
Processing dependencies for stencila==0.24.0+a67987b
Finished processing dependencies for stencila==0.24.0+a67987b

$ python -c "import stencila"

1 个答案:

答案 0 :(得分:0)

在MSYS2上,MSYS2路径转换与bdist_wheel之间存在冲突。解决方法是使用--bdist-dir选项指定临时构建目录的绝对路径(不应该是&#34;构建&#34;因为bdist_wheel删除此目录意味着每次都重新进行重建):

python setup.py bdist_wheel --bdist-dir=$PWD/build-temp