2016-07-19 59 views
0

我正在嘗試構建一個使用Windows 7 VirtualBox虛擬機上的MSYS2 MINGW64 shell的Python包。該軟件包在Linux上成功安裝並導入。bdist_wheel無法在MSYS2下工作

我可以建立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" 

回答

0

在MSYS2之間存在衝突與MSYS2路徑轉換和bdist_wheel。一種解決方法是指定一個絕對路徑使用--bdist-dir選項的臨時構建目錄(不應該是「建立」,因爲bdist_wheel刪除該目錄,這意味着每次新鮮重建):

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