Python包装:pyproject.toml vs setup_requires中的构建要求

发布于 2025-01-21 11:50:45 字数 918 浏览 5 评论 0 原文

在某种复杂的python setup.py 配置中,通常需要已经存在的其他库才能执行 setuptools.setups.setup 。就我而言,这将是 setuptools> = 45.0 cython> = 0.29 。现在,我有两个选项来声明这些构建时间要求(不要将通常在 unignts.txt 文件中找到的标准包装安装要求混淆),以将该项目运送到PYPI:

  1. 手动编写该项目 setup_requires 参数中的要求作为 setup.py 的一部分:
#setup.py
from setuptools import setup
#...
setup(
    name='bla',
    #...
    setup_requires = ['setuptools>=45.0', 'cython>=0.29'],
)
  1. 将这些要求写入 pep518
#pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools>=45.0", "cython>=0.29"]

它们是否可交换?应该使用哪一个,为什么?

In somewhat complex Python setup.py configurations, one typically needs other libraries already present in order to execute setuptools.setup. In my case, this would be setuptools>=45.0 and cython>=0.29. Now, I have two options to declare these build-time requirements (not to confuse with standard package installation requirements typically found in a requirements.txt file) in order to ship this project to PyPI:

  1. Manually write the requirements as part of setup.py in the setup_requires argument:
#setup.py
from setuptools import setup
#...
setup(
    name='bla',
    #...
    setup_requires = ['setuptools>=45.0', 'cython>=0.29'],
)
  1. Write these requirements into a separate pyproject.toml file following PEP518:
#pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools>=45.0", "cython>=0.29"]

Are they exchangeable? Which one should be used and why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百变从容 2025-01-28 11:50:45

创建上述PEP是为了解决部分。 包装python 建议使用第二种方法。

The aforementioned PEP was created to address the limitations of the 1st approach that are listed in the Rationale section. Packaging Python recommends using the 2nd approach.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文