I have an old project created with poetry. The pyproject.toml create by poetry is the following:
[tool.poetry]
name = "Dota2Learning"
version = "0.3.0"
description = "Statistics and Machine Learning for your Dota2 Games."
license = "MIT"
readme = "README.md"
homepage = "Coming soon..."
repository = "https://github.com/drigols/dota2learning/"
documentation = "Coming soon..."
include = ["CHANGELOG.md"]
authors = [
"drigols <drigols.creative@gmail.com>",
]
maintainers = [
"drigols <drigols.creative@gmail.com>",
]
keywords = [
"dota2",
"statistics",
"machine Learning",
"deep learning",
]
[tool.poetry.scripts]
dota2learning = "dota2learning.cli.main:app"
[tool.poetry.dependencies]
python = "^3.10"
requests = "^2.27.1"
typer = {extras = ["all"], version = "^0.4.1"}
install = "^1.3.5"
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"
[tool.poetry.dev-dependencies]
black = {extras = ["jupyter"], version = "^22.3.0"}
pre-commit = "^2.19.0"
flake8 = "^4.0.1"
reorder-python-imports = "^3.1.0"
pyupgrade = "^2.34.0"
coverage = "^6.4.1"
[tool.black]
line-length = 79
include = '\.pyi?$' # All Python files
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/drigols/dota2learning/issues"
If a run "pip install ." it's worked for me, however, now I want to follow the new approach without poetry to manage the project and dependencies. Then I created a new pyproject.toml (manually):
[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 <drigols.creative@gmail.com>",
]
maintainers = [
"drigols <drigols.creative@gmail.com>",
]
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
)/
'''
The problem now is that the pip command "pip install ." don't work:
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.
It's like pip doesn't know how to install the dependencies from pyproject.toml unlike poetry's approach and I don't understand why.
THE PROBLEM WAS SOLVED! A edited the pyproject.toml to:
[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 = "drigols.creative@gmail.com" },
]
maintainers = [
{ name = "Rodrigo Leite", email = "drigols.creative@gmail.com" },
]
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
)/
'''
Multiple issues:
1. As the error message clearly states, there is an issue with the As of December 2024, it seems like this should be fine. See specification.license
key under the [project]
section. Its value should be a table.
2. The new pyproject.toml
file that you are showing us is missing the [build-system]
section. If this section is absent, then the build front-ends (such as pip), will assume that the build back-end of this project is setuptools
(see PEP 517 and PEP 518), and not poetry
/poetry-core
which is probably what you wanted.
3. As of today, Poetry is not compatible with this new [project]
section for pyproject.toml
files. Poetry has not implemented the PEP 621
changes yet, so that would not work anyway, unless the project changes its build back-end from Poetry to another build back-end.