相关疑难解决方法(0)

'pip setup.py bdist_wheel'不再构建强制非纯轮子

我有一个项目在Linux上使用C扩展编译,但在Windows上没有它们.当我第一次产生的车轮文件在Windows上python setup.py bdist_wheel,他们成为普遍的,我无法将它们上传到PyPI将这些万向轮被优先pip用于安装在.tar.gz上传(从结果python setup.py sdist).

围绕这个的诀窍是在setup.py:

Distribution.is_pure = lambda *args: False
Run Code Online (Sandbox Code Playgroud)

或通过子类化Distribution:

class BinaryDistribution(Distribution):
    def is_pure(self):
        return False
Run Code Online (Sandbox Code Playgroud)

setup()使用extra关键字参数在setup.py中 调用distclass=BinaryDistribution,.

这一切都在我的运行Windows XP 64的VM上运行良好,该版本具有32和64位版本的Python 2.6/2.7/3.3/3.4和pypy,仅用于此目的.一个简单的批处理文件给了我:

dist/pkg-1.0-cp26-none-win32.whl
dist/pkg-1.0-cp26-none-win_amd64.whl
dist/pkg-1.0-cp27-none-win32.whl
dist/pkg-1.0-cp27-none-win_amd64.whl
dist/pkg-1.0-cp33-none-win32.whl
dist/pkg-1.0-cp33-none-win_amd64.whl
dist/pkg-1.0-cp34-none-win32.whl
dist/pkg-1.0-cp34-none-win_amd64.whl
Run Code Online (Sandbox Code Playgroud)

pip当你pip在Windows上运行时,适当的软件包可以下载和安装,当你pip在Linux上运行时,你可以获得

pkg-1.0.tar.gz
Run Code Online (Sandbox Code Playgroud)

其中包括在安装过程中编译的C源代码.

问题始于我没有备用Windows 7许可的机器,我可以安装Python 3.5(它不安装在EOL XP上).所以我调查了Appveyor并创建了appveyor.yml:

environment:
  matrix:
    - PYTHON: C:\Python27
    - PYTHON: C:\Python33
    - PYTHON: C:\Python34
    - PYTHON: C:\Python35
    - PYTHON: …
Run Code Online (Sandbox Code Playgroud)

python windows pypi appveyor python-wheel

7
推荐指数
3
解决办法
4750
查看次数

标签 统计

appveyor ×1

pypi ×1

python ×1

python-wheel ×1

windows ×1