Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Pure-Python wheel

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?

like image 283
seadugo Avatar asked Jul 22 '15 20:07

seadugo


2 Answers

This part of the filename is controlled by the bdist_wheel option called python tag:

python2 setup.py bdist_wheel --help | grep python-tag
  --python-tag      Python implementation compatibility tag (default: 'py2')

However the default is generally 'py2' (or 'py3' for a python3 runtime), so to get a platform-specific wheel you must have something else in your configuration that is not shown in the question.

Regardless, you can specify the tag explicitly in your setup file:

from setuptools import setup

setup(
    name="foo",
    version="0.0.1",
    ...
    options={"bdist_wheel": {"python_tag": "cp27"}},
)

This configuration will create a wheel named foo-0.0.1-cp27-none-any.whl.

like image 108
wim Avatar answered Sep 27 '22 20:09

wim


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',
    ],
)
like image 30
seadugo Avatar answered Sep 27 '22 18:09

seadugo