How to create a Pure-Python wheel

雨燕双飞 提交于 2019-12-19 06:52:05

问题


From the following setup.py file, I am trying to create a pure-python wheel from a project that should contain only python 2.7 code.

from setuptools import setup

setup(
    name='foo',
    version='0.0.1',
    description='',
    url='',
    install_requires=[
        'bpython',
        'Django==1.8.2',
    ],
)

However, when I run python setup.py bdist_wheel the wheel file that is generated is platform specific foo-0.0.1-cp27-none-macosx_10_9_x86_64.whl wheel file instead of the expected foo-0.0.1-cp27-none-any.whl. When I try to install this wheel on a different platform it fails saying it is not compatible with this Python.

I there something I need to change about the setup.py file or python interpreter, perhaps, that will allow this wheel to be used on any platform?


回答1:


The simplistic way is to add --universal to your commandline, as you can see from running python setup.py bdist_wheel --help:

  --universal       make a universal wheel (default: false)

Alternatively you can add a setup.cfg file next to your setup.py that takes care of this:

[bdist_wheel]
universal = 1

If you don't like yet another configuration file clobbering your package, you can just write such a file in your setup.py just before it calls setup() and then remove it after that call returns, this is what I do in the shared setup.py for all my projects on PyPI e.g. used in ruamel.yaml.




回答2:


Adding the classifiers field to my setup.py fixed this issue.

from setuptools import setup

setup(
    name='foo',
    version='0.0.1',
    description='',
    url='',
    classifiers=[
        'Programming Language :: Python :: 2.7',
    ],
    install_requires=[
        'bpython',
        'Django==1.8.2',
    ],
)


来源:https://stackoverflow.com/questions/31573107/how-to-create-a-pure-python-wheel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!