[英]How to build a universal wheel with pyproject.toml
This is the project directory structure这是项目目录结构
.
├── meow.py
└── pyproject.toml
0 directories, 2 files
This is the meow.py
:这是
meow.py
:
def main():
print("meow world")
This is the pyproject.toml
:这是
pyproject.toml
:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "meowpkg"
version = "0.1"
description = "a package that meows"
[project.scripts]
meow_world = "meow:main"
When building this package, no matter whether with python3 -m pip wheel .
在构建这个包时,无论是否使用
python3 -m pip wheel .
or using python3 -m build
, it creates a file named like meowpkg-0.1-py3-none-any.whl
which can not be installed on Python 2.或使用
python3 -m build
,它会创建一个名为meowpkg-0.1-py3-none-any.whl
的文件,该文件无法安装在 Python 2 上。
$ python2.7 -m pip install meowpkg-0.1-py3-none-any.whl
ERROR: meowpkg-0.1-py3-none-any.whl is not a supported wheel on this platform.
But "meowpkg" actually works on Python 2 as well.但是“meowpkg”实际上也适用于 Python 2。 How to instruct setuptools and/or wheel to create a universal wheel tagged like
meowpkg-0.1-py2.py3-none-any.whl
, without using the old setup.cfg
/ setup.py
ways?如何指示 setuptools 和/或 wheel 创建标记为
meowpkg-0.1-py2.py3-none-any.whl
的通用轮,而不使用旧的setup.cfg
/ setup.py
方式?
Current workaround:当前解决方法:
echo "[bdist_wheel]\nuniversal=1" > setup.cfg && python3 -m build && rm setup.cfg
Add this section into the pyproject.toml
:将此部分添加到
pyproject.toml
:
[tool.distutils.bdist_wheel]
universal = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.