Search code examples
pythondistutilspython-wheel

Build python wheels for different platforms


I have a library which needs a precompiled extension modlue. Consider following file layout:

lib
  |--- win32_py32
  |       |--- _lib.py
  |---- win32_py32
          |--- _lib.py

How can I build 2 different wheel-packages which only contains the correct binary depending on the platform?


Solution

  • I would do something like this:

    lib
     |------ lib.py
     |------ platform_1
     |           |------- _lib.py
     |           
     |------ platform_2
     |           |------- _lib.py
    

    and in lib.py

    # this module becomes the _lib module for one platform of either 1 or 2
    if platform == 1:
        from .platform_1._lib import * # python 3 import
    if platform == 2:
        from .platform_2._lib import *