How do I get the python wheel to be platform specific when I build it?

I am working on a python2 package which setup.py

contains some custom installation commands. These commands actually generate some Rust code and output some files .dylib

that are moved to the python package.

The important point is that the Rust code is outside the python package.

setuptools

should be automatically detected if the python package is pure python or platform specific (if it contains some C extensions, for example). In my case, when I run python setup.py bdist_wheel

, I created the wheel is marked as a pure python wheel: <package_name>-<version>-py2-none-any.whl

. This is problematic because I need to run this code on different platforms and therefore I need to create one wheel per platform.

Is there a way when you create the wheel to force the assembly to be platform specific?

+3


source to share


1 answer


Here is the code I usually look at uwsgi

Basic approach:

setup.py



# ...

try:
    from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
    class bdist_wheel(_bdist_wheel):
        def finalize_options(self):
            _bdist_wheel.finalize_options(self)
            self.root_is_pure = False
except ImportError:
    bdist_wheel = None

setup(
    # ...
    cmdclass={'bdist_wheel': bdist_wheel},
)

      

The bit root_is_pure

tells the wheeled hardware to build a non-purelib ( pyX-none-any

) wheel . You can also get the fancier by specifying that there are platform-specific binaries, but no cpython abi specific components.

+5


source







All Articles