python - 为不同平台构建 python wheels

标签 python distutils python-wheel

我有一个需要预编译扩展模块的库。考虑以下文件布局:

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

我如何构建 2 个不同的 wheel-packages,根据平台只包含正确的二进制文件?

最佳答案

我会做这样的事情:

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

并在 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 *

关于python - 为不同平台构建 python wheels,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19575341/

相关文章:

python - python 条件 (if) 语句是否有最大长度?

python - `setup.py sdist` 是如何工作的?

覆盖 cmdclass 时忽略 python setuptools install_requires

python - 如何覆盖 setup.py 默认使用的编译器 (GCC) 标志?

python - sdist/bdist_wheel 在 Linux 中不包含 pyc,但在 Windows 中包含

conda 骨架失败

python - 正则表达式匹配中的变音符号(通过语言环境?)

python - 将 numpy 数组转换为日期时间列表

python - 如何在 python wheel 包中包含外部库

python - Flask-RESTful 别名