Skip to content

docs: add additional information on specifying required python versions #10104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions docs/pyproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,26 @@ If you have multiple repositories configured, you can explicitly tell poetry whe
requests = { version = "^2.13.0", source = "private" }
```

{{% note %}}
Be aware that declaring the python version for which your package
is compatible is mandatory:
You may also specify your project's compatible python versions in this section, instead of or in addition to `project.requires-python`.

```toml
[tool.poetry.dependencies]
python = "^3.7"
```

{{% note %}}
If you specify the compatible python versions in both `tool.poetry.dependencies` and in `project.requires-python`, then Poetry will use the information in `tool.poetry.dependencies` for locking, but the python versions must be a subset of those allowed by `project.requires-python`.

For example, the following is invalid and will result in an error, because versions `4.0` and greater are allowed by `tool.poetry.dependencies`, but not by `project.requires-python`.

```toml
[project]
# ...
requires-python = ">=3.8,<4.0"

[tool.poetry.dependencies]
python = ">=3.8" # not valid!
```
{{% /note %}}

You can organize your dependencies in [groups]({{< relref "managing-dependencies#dependency-groups" >}})
Expand Down