1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
|
.. _configuration:
=====================
Configuration
=====================
``whey`` is configured in the ``pyproject.toml`` file defined in :pep:`517` and :pep:`518`.
.. note::
``whey`` only supports `TOML v0.5.0 <https://toml.io/en/v0.5.0>`_.
``pyproject.toml`` files using features of newer TOML versions may not parse correctly.
``[build-system]``
-------------------
``whey`` must be set as the ``build-backend`` in the ``[build-system]`` table.
:bold-title:`Example`:
.. code-block:: TOML
[build-system]
requires = [ "whey",]
build-backend = "whey"
``[project]``
-------------------
The metadata used by ``whey`` is defined in the ``[project]`` table, per :pep:`621`.
As a minimum, the table MUST contain the keys :tconf:`~project.name` and :tconf:`~project.version` [1]_.
.. [1] Other tools, such as flit_ and trampolim_, may support determining :tconf:`project.version`
dynamically without specifying a value in ``pyproject.toml``.
.. _flit: https://flit.readthedocs.io/en/latest/
.. _trampolim: https://github.com/FFY00/trampolim
.. tconf:: project.name
:type: :toml:`String`
:required: True
The name of the project.
Ideally, the name should be normalised to lowercase, with underscores replaced by hyphens.
The name may only contain ASCII letters, numbers, and the following symbols: ``._-`` .
It must start and end with a letter or number.
This key is required, and MUST be defined statically.
:bold-title:`Example:`
.. code-block:: TOML
[project]
name = "spam"
.. latex:clearpage::
.. tconf:: project.version
:type: :toml:`String`
The version of the project as supported by :pep:`440`.
With ``whey`` this key is required, and must be defined statically.
Other backends may support determining this value automatically if it is listed in :tconf:`project.dynamic`.
:bold-title:`Example:`
.. code-block:: TOML
[project]
version = "2020.0.0"
.. tconf:: project.description
:type: :toml:`String`
A short summary description of the project.
PyPI will display this towards the top of the `project page`_.
A longer description can be provided as :tconf:`~project.readme`.
:bold-title:`Example:`
.. code-block:: TOML
[project]
description = "Lovely Spam! Wonderful Spam!"
.. tconf:: project.readme
:type: :toml:`String` or :toml:`table <Table>`
The full description of the project (i.e. the README).
The field accepts either a string or a table.
If it is a string then it is the relative path to a text file containing the full description.
The file's encoding MUST be UTF-8, and have one of the following content types:
* ``text/markdown``, with a a case-insensitive ``.md`` suffix.
* ``text/x-rst``, with a a case-insensitive ``.rst`` suffix.
* ``text/plain``, with a a case-insensitive ``.txt`` suffix.
The readme field may instead be a table with the following keys:
* ``file`` -- a string value representing a relative path to a file containing the full description.
* ``text`` -- a string value which is the full description.
* ``content-type`` -- (required) a string specifying the content-type of the full description.
* ``charset`` -- (optional, default UTF-8) the encoding of the ``file``.
The ``file`` and ``text`` keys are mutually exclusive, but one must be provided in the table.
PyPI will display this on the `project page`_
:bold-title:`Examples:`
.. code-block:: TOML
[project]
readme = "README.rst"
.. code-block:: toml
[project]
readme = {file = "README.md", content-type = "text/markdown", encoding = "UTF-8"}
.. code-block:: TOML
[project.readme]
text = "Spam is a brand of canned cooked pork made by Hormel Foods Corporation."
content-type = "text/x-rst"
.. tconf:: project.requires-python
:type: :toml:`String`
The Python version requirements of the project, as a :pep:`508` specifier.
.. latex:vspace:: -5px
:bold-title:`Example:`
.. code-block:: TOML
[project]
requires-python = ">=3.6"
.. tconf:: project.license
:type: :toml:`Table`
The table may have one of two keys:
* ``file`` -- a string value that is a relative file path to the file which contains
the license for the project. The file's encoding MUST be UTF-8.
* ``text`` -- string value which is the license of the project.
These keys are mutually exclusive.
.. latex:vspace:: -5px
:bold-title:`Examples:`
.. code-block:: toml
[project]
license = {file = "LICENSE.rst"}
.. code-block:: TOML
[project.license]
file = "COPYING"
.. code-block:: toml
[project.license]
text = """
This software may only be obtained by sending the author a postcard,
and then the user promises not to redistribute it.
"""
.. tconf:: project.authors
:type: :toml:`Array` of :toml:`tables <Table>` with string keys and values
The tables list the people or organizations considered to be the "authors" of the project.
Each table has 2 keys: ``name`` and ``email``. Both keys are optional, and both values must be strings.
* The ``name`` value MUST be a valid email name (i.e. whatever can be put as a name,
before an email, in :rfc:`822`) and not contain commas.
* The ``email`` value MUST be a valid email address.
.. latex:clearpage::
:bold-title:`Examples:`
.. code-block:: toml
[project]
authors = [
{name = "Dominic Davis-Foster", email = "dominic@davis-foster.co.uk"},
{name = "The pip developers", email = "distutils-sig@python.org"}
]
.. code-block:: toml
[[project.authors]]
name = "Tzu-ping Chung"
[[project.authors]]
email = "hi@pradyunsg.me"
.. tconf:: project.maintainers
:type: :toml:`Array` of :toml:`tables <Table>` with string keys and values
The tables list the people or organizations considered to be the "maintainers" of the project.
This field otherwise functions the same as :tconf:`~project.authors`.
:bold-title:`Example:`
.. code-block:: toml
[project]
authors = [
{email = "hi@pradyunsg.me"},
{name = "Tzu-ping Chung"}
]
maintainers = [
{name = "Brett Cannon", email = "brett@python.org"}
]
.. tconf:: project.keywords
:type: :toml:`Array` of :toml:`strings <String>`
The keywords for the project.
These can be used by community members to find projects based on their desired criteria.
:bold-title:`Example:`
.. code-block:: TOML
[project]
keywords = [ "egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor",]
.. tconf:: project.classifiers
:type: :toml:`Array` of :toml:`strings <String>`
The `trove classifiers`_ which apply to the project.
Classifiers describe who the project is for, what systems it can run on, and how mature it is.
These can then be used by community members to find projects based on their desired criteria.
.. latex:clearpage::
:bold-title:`Example:`
.. code-block:: toml
[project]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python"
]
.. tconf:: project.urls
:type: :toml:`Table`, with keys and values of :toml:`strings <String>`
A table of URLs where the key is the URL label and the value is the URL itself.
The URL labels are free text, but may not exceed 32 characters.
:bold-title:`Example:`
.. code-block:: TOML
[project.urls]
homepage = "https://example.com"
documentation = "https://readthedocs.org"
repository = "https://github.com"
changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"
.. tconf:: project.scripts
:type: :toml:`Table`, with keys and values of :toml:`strings <String>`
The console scripts provided by the project.
The keys are the names of the scripts and the values are the object references
in the form ``module.submodule:object``.
See the `entry point specification`_ for more details.
:bold-title:`Example:`
.. code-block:: toml
[project.scripts]
spam-cli = "spam:main_cli"
# One which depends on extras:
foobar = "foomod:main_bar [bar,baz]"
.. tconf:: project.gui-scripts
:type: :toml:`Table`, with keys and values of :toml:`strings <String>`
The graphical application scripts provided by the project.
The keys are the names of the scripts, and the values are the object references
in the form ``module.submodule:object``.
See the `entry point specification`_ for more details.
:bold-title:`Example:`
.. code-block:: TOML
[project.gui-scripts]
spam-gui = "spam.gui:main_gui"
.. latex:clearpage::
.. tconf:: project.entry-points
:type: :toml:`Table` of :toml:`tables <!Table>`, with keys and values of :toml:`strings <String>`
Each sub-table's name is an entry point group.
Users MUST NOT create nested sub-tables but instead keep the entry point groups to only one level deep.
Users MUST NOT create sub-tables for ``console_scripts`` or ``gui_scripts``.
Use ``[project.scripts]`` and ``[project.gui-scripts]`` instead.
See the `entry point specification`_ for more details.
:bold-title:`Example:`
.. code-block:: toml
[project.entry-points."spam.magical"]
tomatoes = "spam:main_tomatoes"
# pytest plugins refer to a module, so there is no ':obj'
[project.entry-points.pytest11]
nbval = "nbval.plugin"
.. _entry point specification: https://packaging.python.org/specifications/entry-points/
.. tconf:: project.dependencies
:type: :toml:`Array` of :pep:`508` strings
The dependencies of the project.
Each string MUST be formatted as a valid :pep:`508` string.
:bold-title:`Example:`
.. code-block:: toml
[project]
dependencies = [
"httpx",
"gidgethub[httpx]>4.0.0",
"django>2.1; os_name != 'nt'",
"django>2.0; os_name == 'nt'"
]
.. tconf:: project.optional-dependencies
:type: :toml:`Table` with values of :toml:`arrays <Array>` of :pep:`508` strings
The optional dependencies of the project.
* The keys specify an extra, and must be valid Python identifiers.
* The values are arrays of strings, which must be valid :pep:`508` strings.
:bold-title:`Example:`
.. code-block:: toml
[project.optional-dependencies]
test = [
"pytest < 5.0.0",
"pytest-cov[all]"
]
.. latex:clearpage::
.. tconf:: project.dynamic
:type: :toml:`Array` of :toml:`strings <String>`
Specifies which fields listed by :pep:`621` were intentionally unspecified
so ``whey`` can provide such metadata dynamically.
Whey currently only supports :tconf:`~project.classifiers`, :tconf:`~project.dependencies`,
and :tconf:`~project.requires-python` as dynamic fields.
Other tools may support different dynamic fields.
:bold-title:`Example:`
.. code-block:: toml
[project]
dynamic = [ "classifiers",]
[tool.whey]
base-classifiers = [
"Development Status :: 3 - Alpha",
"Typing :: Typed",
]
``[tool.whey]``
-------------------
.. tconf:: tool.whey.package
:type: :toml:`String`
The path to the package to distribute, relative to the directory containing ``pyproject.toml``.
This defaults to :tconf:`project.name` if unspecified.
:bold-title:`Example:`
.. code-block:: TOML
[project]
name = "domdf-python-tools"
[tool.whey]
package = "domdf_python_tools"
.. tconf:: tool.whey.source-dir
:type: :toml:`String`
The name of the directory containing the project's source.
This defaults to ``'.'`` if unspecified.
:bold-title:`Examples:`
.. code-block:: TOML
[project]
name = "flake8"
.. code-block:: TOML
[tool.whey]
source-dir = "src/flake8"
.. tconf:: tool.whey.additional-files
:type: :toml:`Array` of :toml:`strings <String>`
A list of `MANIFEST.in <https://packaging.python.org/guides/using-manifest-in/>`_-style
entries for additional files to include in distributions.
The supported commands are:
========================================================= ==================================================================================================
Command Description
========================================================= ==================================================================================================
:samp:`include {pat1} {pat2} ...` Add all files matching any of the listed patterns
:samp:`exclude {pat1} {pat2} ...` Remove all files matching any of the listed patterns
:samp:`recursive-include {dir-pattern} {pat1} {pat2} ...` Add all files under directories matching ``dir-pattern`` that match any of the listed patterns
:samp:`recursive-exclude {dir-pattern} {pat1} {pat2} ...` Remove all files under directories matching ``dir-pattern`` that match any of the listed patterns
========================================================= ==================================================================================================
``whey`` was built with type hints in mind, so it will automatically include any ``py.typed`` files and ``*.pyi`` stub files automatically.
.. note::
If using :tconf:`tool.whey.source-dir`, the entries for files within the package
must start with the value of :tconf:`~tool.whey.source-dir`.
For example, if :tconf:`~tool.whey.source-dir` is ``'src'`` and the package
is at ``src/spam`` an entry might be ``include src/spam/template.scss``.
.. raw:: latex
\begin{minipage}{\textwidth}
:bold-title:`Examples:`
.. code-block:: toml
[tool.whey]
additional-files = [
"include domdf_python_tools/google-10000-english-no-swears.txt",
"recursive-exclude domdf_python_tools *.json",
]
.. code-block:: toml
[tool.whey]
source-dir = "src"
additional-files = [
"include src/domdf_python_tools/google-10000-english-no-swears.txt",
"recursive-exclude src/domdf_python_tools *.json",
]
.. raw:: latex
\end{minipage}
.. tconf:: tool.whey.license-key
:type: :toml:`String`
An identifier giving the project's license.
This is used for the :core-meta:`License` field in the Core Metadata,
and to add the appropriate `trove classifier`_.
It is recommended to use an `SPDX Identifier`_, but note that not all map to classifiers.
:bold-title:`Example:`
.. code-block:: TOML
[tool.whey]
license-key = "MIT"
.. tconf:: tool.whey.base-classifiers
:type: :toml:`Array` of :toml:`strings <String>`
A list of `trove classifiers <https://pypi.org/classifiers/>`_.
This list will be extended with the appropriate classifiers for the :tconf:`~tool.whey.license-key`
and the supported :tconf:`~tool.whey.platforms`, :tconf:`~tool.whey.python-implementations`
and :tconf:`~tool.whey.python-versions`.
This field is ignored if :tconf:`~project.classifiers` is not listed in :tconf:`project.dynamic`
:bold-title:`Example:`
.. code-block:: toml
[project]
dynamic = [ "classifiers", ]
[tool.whey]
base-classifiers = [
"Development Status :: 3 - Alpha",
"Typing :: Typed",
]
.. tconf:: tool.whey.platforms
:type: :toml:`Array` of :toml:`strings <String>`
A list of supported platforms. This is used to add appropriate `trove classifiers`_
and is listed under :core-meta:`Platform` in the Core Metadata.
:bold-title:`Example:`
.. code-block:: TOML
[tool.whey]
platforms = [ "Windows", "Linux",]
.. tconf:: tool.whey.python-implementations
:type: :toml:`Array` of :toml:`strings <String>`
A list of supported Python implementations. This can be used to add appropriate `trove classifiers`_.
:bold-title:`Example:`
.. code-block:: TOML
[tool.whey]
python-implementations = [ "CPython", "PyPy",]
.. tconf:: tool.whey.python-versions
:type: :toml:`Array` of :toml:`strings <String>`
A list of supported Python versions. This can be used to add appropriate `trove classifiers`_
and dynamically determine the minimum required Python version for :tconf:`project.requires-python`.
:bold-title:`Example:`
.. code-block:: toml
[tool.whey]
python-versions = [
"3.6",
"3.7",
]
.. _trove classifier: https://pypi.org/classifiers/
.. _SPDX Identifier: https://spdx.org/licenses/
.. _project page: https://pypi.org/project/whey/
.. _trove classifiers: https://pypi.org/classifiers/
Environment Variables
--------------------------
.. envvar:: CHECK_README
Setting this to ``0`` disables the optional README validation feature,
which checks the README will render correctly on PyPI.
.. envvar:: SOURCE_DATE_EPOCH
To make reproducible builds, set this to a timestamp as a number of seconds since
1970-01-01 UTC, and document the value you used.
On Unix systems, you can get a value for the current time by running:
.. prompt:: bash
date +%s
.. note:: The timestamp cannot be before 1980-01-01 or after 2107-12-31.
.. seealso::
`The SOURCE_DATE_EPOCH specification <https://reproducible-builds.org/specs/source-date-epoch/>`_
.. envvar:: WHEY_VERBOSE
Run whey in verbose mode. This includes printing the names of the files being added to the sdist or wheel.
If using whey's command-line interface, this option defaults to ``0``.
Setting it to ``1`` has the same meaning as the :option:`-v / --verbose <whey -v>` option.
If using whey's :pep:`517` backend, this option defaults to ``1``.
Setting it to ``0`` disables the verbose output.
.. envvar:: WHEY_TRACEBACK
Show the complete traceback on error.
This option defaults to ``0``.
Setting it to ``1`` has the same meaning as the :option:`-T / --traceback <whey -T>` option, both for the command-line interface and the :pep:`517` backend.
Complete Example
------------------
This is an example of a complete ``pyproject.toml`` file for :pep:`621`.
For an explanation of each field, see the :ref:`configuration` section.
.. literalinclude:: pyproject.toml
:caption: :download:`pyproject.toml`
:language: toml
|