Skip to content

Commit 481f2eb

Browse files
authored
Merge pull request #1065 from abravalheri/main
docs: add note about opting into PEP 621
2 parents 63a45ab + 0ccd623 commit 481f2eb

1 file changed

Lines changed: 18 additions & 31 deletions

File tree

docs/options.md

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ This option can also be set using the [command-line option](#command-line)
402402
> Manually set the Python compatibility of your project
403403
404404
By default, cibuildwheel reads your package's Python compatibility from
405-
`pyproject.toml` following [PEP621](https://www.python.org/dev/peps/pep-0621/)
405+
`pyproject.toml` following the [project metadata specification](https://packaging.python.org/en/latest/specifications/declaring-project-metadata/)
406406
or from `setup.cfg`; finally it will try to inspect the AST of `setup.py` for a
407407
simple keyword assignment in a top level function call. If you need to override
408408
this behaviour for some reason, you can use this option.
@@ -416,42 +416,29 @@ Default: reads your package's Python compatibility from `pyproject.toml`
416416
`setup.py` `setup(python_requires="...")`. If not found, cibuildwheel assumes
417417
the package is compatible with all versions of Python that it can build.
418418

419-
420419
!!! note
421-
Rather than using this option, it's recommended you set
422-
`project.requires-python` in `pyproject.toml` instead:
423-
Example `pyproject.toml`:
420+
Rather than using this environment variable, it's recommended you set this value
421+
statically in a way that your build backend can use it, too. This ensures
422+
that your package's metadata is correct when published on PyPI. This
423+
cibuildwheel-specific option is provided as an override, and therefore is only
424+
available in environment variable form.
425+
426+
- If you have a `pyproject.toml` containing a `[project]` table, you can
427+
specify `requires-python` there.
424428

429+
```toml
425430
[project]
431+
...
426432
requires-python = ">=3.6"
433+
```
427434

428-
# Aside - in pyproject.toml you should always specify minimal build
429-
# system options, like this:
430-
431-
[build-system]
432-
requires = ["setuptools>=42", "wheel"]
433-
build-backend = "setuptools.build_meta"
434-
435-
436-
Currently, setuptools has not yet added support for reading this value from
437-
pyproject.toml yet, and so does not copy it to Requires-Python in the wheel
438-
metadata. This mechanism is used by pip to scan through older versions of
439-
your package until it finds a release compatible with the current version
440-
of Python compatible when installing, so it is an important value to set if
441-
you plan to drop support for a version of Python in the future.
442-
443-
If you don't want to list this value twice, you can also use the setuptools
444-
specific location in `setup.cfg` and cibuildwheel will detect it from
445-
there. Example `setup.cfg`:
446-
447-
[options]
448-
python_requires = ">=3.6"
449-
435+
Note that not all build backends fully support using a `[project]` table yet;
436+
specifically setuptools just added experimental support in version 61.
437+
Adding `[project]` to `pyproject.toml` requires all the other supported
438+
values to be specified there, or to be listed in `dynamic`.
450439

451-
This option is not available in `pyproject.toml` under
452-
`tool.cibuildwheel.project-requires-python`, since it should be set with the
453-
[PEP621](https://www.python.org/dev/peps/pep-0621/) location instead,
454-
`project.requires-python`.
440+
- If you're using setuptools, [you can set this value in `setup.cfg` (preferred) or `setup.py`](https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#python-requirement)
441+
and cibuildwheel will read it from there.
455442

456443
#### Examples
457444

0 commit comments

Comments
 (0)