问题要安装pyproject.toml依赖项 我有一个由诗歌创造的旧项目。 pyproject.toml由诗歌创造是以下内容: [工具。 名称=“ dota2learning” 版本=“ 0.3.0” 描述=“ stati ...

问题描述 投票:0回答:1

如果运行“ PIP安装。”它对我有用,但是现在,我想在没有诗歌的情况下遵循新方法来管理项目和依赖关系。然后我创建了一个新的pyproject.toml(手动):

[project] name = "Dota2Learning" version = "2.0.0" description = "Statistics and Machine Learning for your Dota2 Games." license = "MIT" readme = "README.md" homepage = "" requires-python = ">=3.10" repository = "https://github.com/drigols/dota2learning/" documentation = "" include = ["CHANGELOG.md"] authors = [ "drigols <[email protected]>", ] maintainers = [ "drigols <[email protected]>", ] keywords = [ "dota2", "statistics", "machine Learning", "deep learning", ] dependencies = [ "requests>=2.27.1", "typer>=0.4.1", "SQLAlchemy>=1.4.39", "PyMySQL>=1.0.2", "cryptography>=37.0.4", "pydantic>=1.9.1", "rich>=12.5.1", "fastapi>=0.79.0", "uvicorn>=0.18.2", ] [project.optional-dependencies] # Dev dependencies. dev = [ "black>=22.3.0", "pre-commit>=2.19.0", "flake8>=4.0.1", "reorder-python-imports>=3.1.0", "pyupgrade>=2.34.0", ] # Testing dependencies. test = [ "coverage>=6.4.1", ] # Docs dependencies. doc = [] [project.scripts] dota2learning = "dota2learning.cli.main:app" [tool.black] line-length = 79 include = '\.pyi?$' # All Python files exclude = ''' /( \.git | \.hg | \.mypy_cache | \.tox | \.venv | _build | buck-out | build | dist )/ '''
现在问题是pip命令

“ pip install。”不起作用:

Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [89 lines of output] configuration error: `project.license` must be valid exactly by one definition (2 matches found): - keys: 'file': {type: string} required: ['file'] - keys: 'text': {type: string} required: ['text'] DESCRIPTION: `Project license <https://www.python.org/dev/peps/pep-0621/#license>`_. GIVEN VALUE: "MIT" OFFENDING RULE: 'oneOf' DEFINITION: { "oneOf": [ { "properties": { "file": { "type": "string", "$$description": [ "Relative path to the file (UTF-8) which contains the license for the", "project." ] } }, "required": [ "file" ] }, { "properties": { "text": { "type": "string", "$$description": [ "The license of the project whose meaning is that of the", "`License field from the core metadata", "<https://packaging.python.org/specifications/core-metadata/#license>`_." ] } }, "required": [ "text" ] } ] } Traceback (most recent call last): File "/home/drigols/Workspace/dota2learning/environment/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module> main() File "/home/drigols/Workspace/dota2learning/environment/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/home/drigols/Workspace/dota2learning/environment/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 484, in run_setup super(_BuildMetaLegacyBackend, File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup exec(code, locals()) File "<string>", line 1, in <module> File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup return distutils.core.setup(**attrs) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 159, in setup dist.parse_config_files() File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 867, in parse_config_files pyprojecttoml.apply_configuration(self, filename, ignore_option_errors) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 62, in apply_configuration config = read_configuration(filepath, True, ignore_option_errors, dist) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 126, in read_configuration validate(subset, filepath) File "/tmp/pip-build-env-up7_m__d/overlay/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 51, in validate raise ValueError(f"{error}\n{summary}") from None ValueError: invalid pyproject.toml config: `project.license`. configuration error: `project.license` must be valid exactly by one definition (2 matches found): - keys: 'file': {type: string} required: ['file'] - keys: 'text': {type: string} required: ['text'] [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
pip不知道如何从pyproject.toml安装依赖项,与诗歌的方法不同,我不明白为什么。

问题解决了! A对pyproject.toml进行了编辑:

[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"]  # PEP 508 specifications.
build-backend = "setuptools.build_meta"

# Ignore flat-layout.
[tool.setuptools]
py-modules = []

[project]
name = "Dota2Learning"
version = "2.0.0"
description = "Statistics and Machine Learning for your Dota2 Games."
license = {file = "LICENSE.md"}
readme = "README.md"
requires-python = ">=3.10.0"
authors = [
    { name = "Rodrigo Leite", email = "[email protected]" },
]
maintainers = [
    { name = "Rodrigo Leite", email = "[email protected]" },
]
keywords = [
    "dota2",
    "statistics",
    "machine Learning",
    "deep learning",
]

dependencies = [
    "requests>=2.27.1",
    "typer>=0.4.1",
    "SQLAlchemy>=1.4.39",
    "PyMySQL>=1.0.2",
    "cryptography>=37.0.4",
    "pydantic>=1.9.1",
    "rich>=12.5.1",
    "fastapi>=0.79.0",
    "uvicorn>=0.18.2",
]

[project.optional-dependencies]
# Dev dependencies.
dev = [
    "black>=22.3.0",
    "pre-commit>=2.19.0",
    "flake8>=4.0.1",
    "reorder-python-imports>=3.1.0",
    "pyupgrade>=2.34.0",
]
# Test dependencies.
test = [
    "coverage>=6.4.1",
]
# Doc dependencies.
doc = []

[project.scripts]
# dota2learning = "dota2learning.cli.main:app"

[tool.black]
line-length = 79
include = '\.pyi?$' # All Python files
exclude = '''
/(
    \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | _build
  | buck-out
  | build
  | dist
)/
'''

变性问题:

1.
python pip python-packaging python-poetry pyproject.toml
1个回答
4
投票
license

部分下的

[project]

键存在问题。它的价值应该是一张桌子。参见规定 22。您显示的新文件缺少

pyproject.toml
部分。如果本节不存在,则构建前端(例如PIP)将假设该项目的后端是
[build-system]
(请参阅PEP517

PEP518),而不是setuptools

/
poetry
,这可能是您想要的。
3.3截至今天,诗歌与此新的poetry-core文件不兼容。诗歌尚未实施[project]的变化,因此无论如何都无法正常工作,除非项目将其构建后端从诗歌更改为另一个构建后端。
    
	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.