我目前正在尝试将我们的内部项目从 setup.py
转移到 pyproject.toml
( pep-518 )。如果可能的话,我希望不使用构建后端特定的配置,即使我确实在 [build-system]中指定了后端,
requiend requient
'ing ung。
pyproject.toml
文件或多或少是 setup.py.py.py
文件的直截了当的翻译,根据 setUptools_scm 来确定版本,因此版本
字段最终以 dynamic
e节。
我们用来在我们的 setup
setup.py.py.py 文件中设置 packages
参数,但是我找不到>中的任何相应字段pyproject.toml
,所以我只是省略了它。
使用 Python3 -m构建构建项目时,即使我有 name
five in in In中 [Project]
部分。看来这在构建中很早就破裂了:
$ python -m build .
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools, setuptools_scm[toml]>=6.2, wheel)
* Getting dependencies for sdist...
running egg_info
writing UNKNOWN.egg-info/PKG-INFO
....
我正在使用Python 3.8.11和以下软件包:
build==0.8.0
distlib==0.3.4
filelock==3.4.1
packaging==21.3
pep517==0.12.0
pip==22.0.4
platformdirs==2.4.0
pyparsing==3.0.9
setuptools==62.1.0
six==1.16.0
tomli==1.2.3
virtualenv==20.14.1
wheel==0.37.1
我的(缩写) pyproject.toml
看起来像这样:
[project]
name = "coolproject"
dependencies = [
'pyyaml==5.3',
'anytree==2.8.0',
'pytest'
]
dynamic = [
"version"
]
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm[toml]>=6.2"]
[tool.setuptools_scm]
有什么想法吗?
I'm currently trying to move our internal projects away from setup.py
to pyproject.toml
(PEP-518). I'd like to not use build backend specific configuration if possible, even though I do specify the backend in the [build-system]
section by require
'ing it.
The pyproject.toml
files are more or less straight-forward translations of the setup.py
files, with the metadata set according to PEP-621, including the dependencies
. We are using setuptools_scm
for the determination of the version, therefore the version
field ends up in the dynamic
section.
We used to set the packages
parameter to setup
in our setup.py
files, but I couldn't find any corresponding field in pyproject.toml
, so I simply omitted it.
When building the project using python3 -m build .
, I end up with a package named UNKNOWN
, even though I have the name
field set in the [project]
section. It seems that this breaks very early in the build:
$ python -m build .
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools, setuptools_scm[toml]>=6.2, wheel)
* Getting dependencies for sdist...
running egg_info
writing UNKNOWN.egg-info/PKG-INFO
....
I'm using python 3.8.11 and the following packages:
build==0.8.0
distlib==0.3.4
filelock==3.4.1
packaging==21.3
pep517==0.12.0
pip==22.0.4
platformdirs==2.4.0
pyparsing==3.0.9
setuptools==62.1.0
six==1.16.0
tomli==1.2.3
virtualenv==20.14.1
wheel==0.37.1
My (abbreviated) pyproject.toml
looks like this:
[project]
name = "coolproject"
dependencies = [
'pyyaml==5.3',
'anytree==2.8.0',
'pytest'
]
dynamic = [
"version"
]
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm[toml]>=6.2"]
[tool.setuptools_scm]
Any ideas?
发布评论
评论(2)
如果安装了旧系统版本,则可以创建Debian/Ubuntu“未知”软件包。
解决方法:
https://github.com/pypa/ppy.com/pypa/seteuptools/3269
On Debian/Ubuntu "UNKNOWN" packages can be created if an older system version of setuptools is installed as well.
Workaround:
https://github.com/pypa/setuptools/issues/3269
将 @akx的评论变成答案,以便其他人更容易找到它。
问题可能是系统上过时的PIP/setuptools。显然,我在系统上拥有的19.3.1版本无法安装可以正确处理PEP621元数据的Setuptools版本。
您不能使用
build-system.requires
指令从pyproject.toml中进行新的PIP。如果您无法更新系统PIP,则可以始终以每个用户的方式安装:
您可以走。
Turning @AKX's comments into an answer so that other people can find it more easily.
The problem may be an outdated pip/setuptools on the system. Apparently, version 19.3.1 which I have on my system cannot install a version of setuptools that can handle PEP621 metadata correctly.
You cannot require a new pip from within pyproject.toml using the
build-system.requires
directive.In case you cannot update the system pip, you can always install on a per-user basis:
and you're good to go.