pyproject.toml 文件有什么用? [英] What is pyproject.toml file for?
问题描述
我正要尝试从GitHub下载的Python包,发现它没有setup.py
,所以我无法用
I was about to try Python package downloaded from GitHub, and realized that it did not have a setup.py
, so I could not install it with
pip install -e <folder>
相反,该包有一个 pyproject.toml
文件,该文件似乎与 setup.py
通常具有非常相似的条目.
Instead, the package had a pyproject.toml
file which seems to have very similar entries as the setup.py
usually has.
谷歌搜索引导我进入 PEP-518 并给出了一些批评setup.py
在基本原理部分.但是,它没有明确说明应该避免使用 setup.py
,或者 pyproject.toml
将完全取代 setup.py
>.
Googling lead me into PEP-518 and it gives some critique to setup.py
in Rationale section. However, it does not clearly tell that usage of setup.py
should be avoided, or that pyproject.toml
would as such completely replace setup.py
.
pyproject.toml
是用来替代 setup.py
的东西吗?或者一个包是否应该同时包含 pyproject.toml
和 setup.py
?
如何使用处于可编辑状态的 pyproject.toml
安装项目?
Is the pyproject.toml
something that is used to replace setup.py
? Or should a package come with both, a pyproject.toml
and a setup.py
?
How would one install a project with pyproject.toml
in an editable state?
推荐答案
是的,pyproject.toml
是PEP 518,其中包含 Python 项目的构建系统要求.
Yes, pyproject.toml
is the specified file format of PEP 518 which contains the build system requirements of Python projects.
这样就解决了build-tool依赖鸡和蛋的问题,即pip
可以读取pyproject.toml
以及什么版本的setuptools
或<代码>轮子代码>可能需要.
This solves the build-tool dependency chicken and egg problem, i.e. pip
can read pyproject.toml
and what version of setuptools
or wheel
one may need.
如果您需要 setup.py
进行可编辑的安装,您可以在 setup.py
中使用垫片:
If you need a setup.py
for an editable install, you could use a shim in setup.py
:
#!/usr/bin/env python
import setuptools
if __name__ == "__main__":
setuptools.setup()
这篇关于pyproject.toml 文件有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!