Search code examples
pythonpypidynamic-librarybinarieslanguage-interoperability

How to deal with the "platform specific dynamic library" problem with uploading to PyPI?


I have a Python package that depends on binaries. I've build the linux version and it is available on PyPI. The key was setting the package_data argument to ensure the *.so files were also uploaded to PyPI.

Now I want to do the same thing with Windows, which obviously require *.dll dependencies, rather than *.so. When uploading my package to PyPI, is it possible to upload *.so files for when a user downloads my package on a linux platform and *.dll files for when a user is on windows. The issue I'm foreseeing is that if I have to upload all binaries for all platforms, my package will quickly exceed the size limit for PyPI.


Solution

  • This is what compatibility tags for built distributions are for.

    For example, consider https://pypi.org/project/numpy/#files. It publishes the following wheels:

    • numpy-1.18.5-cp38-cp38-macosx_10_9_x86_64.whl
    • numpy-1.18.5-cp38-cp38-manylinux1_i686.whl
    • numpy-1.18.5-cp38-cp38-manylinux1_x86_64.whl
    • numpy-1.18.5-cp38-cp38-win32.whl
    • numpy-1.18.5-cp38-cp38-win_amd64.whl

    Each of these contain the platform-specific dependencies for the given platform.