2020-08-27 17:26:36 -04:00
|
|
|
PEP: 631
|
|
|
|
Title: Dependency specification in pyproject.toml based on PEP 508
|
|
|
|
Author: Ofek Lev <ofekmeister@gmail.com>
|
|
|
|
Sponsor: Paul Ganssle <paul@ganssle.io>
|
|
|
|
Discussions-To: https://discuss.python.org/t/5018
|
|
|
|
Status: Draft
|
|
|
|
Type: Standards Track
|
|
|
|
Content-Type: text/x-rst
|
|
|
|
Created: 20-Aug-2020
|
|
|
|
Post-History: 20-Aug-2020
|
|
|
|
|
|
|
|
|
|
|
|
Abstract
|
|
|
|
========
|
|
|
|
|
|
|
|
This PEP specifies how to write a project's dependencies in a
|
|
|
|
``pyproject.toml`` file for packaging-related tools to consume
|
|
|
|
using the `fields defined in PEP 621`_.
|
|
|
|
|
|
|
|
Entries
|
|
|
|
=======
|
|
|
|
|
|
|
|
All dependency entries MUST be valid `PEP 508 strings`_.
|
|
|
|
|
|
|
|
Build backends SHOULD abort at load time for any parsing errors.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
from packaging.requirements import InvalidRequirement, Requirement
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
try:
|
|
|
|
Requirement(entry)
|
|
|
|
except InvalidRequirement:
|
|
|
|
# exit
|
|
|
|
|
|
|
|
Specification
|
|
|
|
=============
|
|
|
|
|
|
|
|
dependencies
|
|
|
|
------------
|
|
|
|
|
2020-08-31 15:07:31 -04:00
|
|
|
- Format: array of strings or inline tables
|
2020-08-27 17:26:36 -04:00
|
|
|
- Related core metadata:
|
|
|
|
|
|
|
|
- `Requires-Dist`_
|
|
|
|
|
2020-08-31 15:07:31 -04:00
|
|
|
Every element SHOULD be an `entry <#entries>`_.
|
2020-08-27 17:26:36 -04:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
[project]
|
|
|
|
dependencies = [
|
|
|
|
'PyYAML ~= 5.0',
|
|
|
|
'requests[security] < 3',
|
|
|
|
'subprocess32; python_version < "3.2"',
|
|
|
|
]
|
|
|
|
|
2020-08-31 15:07:31 -04:00
|
|
|
Any element MAY be an inline table to support possible future functionality.
|
|
|
|
Backends MUST silently ignore these until the specification is extended.
|
|
|
|
|
2020-08-27 17:26:36 -04:00
|
|
|
optional-dependencies
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
- Format: table
|
|
|
|
- Related core metadata:
|
|
|
|
|
|
|
|
- `Provides-Extra`_
|
|
|
|
- `Requires-Dist`_
|
|
|
|
|
|
|
|
Each key is the name of the provided option, with each value being the same type as
|
2020-08-31 15:07:31 -04:00
|
|
|
the `dependencies <#dependencies>`_ field i.e. an array of strings or inline tables.
|
2020-08-27 17:26:36 -04:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
[project.optional-dependencies]
|
|
|
|
tests = [
|
|
|
|
'coverage>=5.0.3',
|
|
|
|
'pytest',
|
|
|
|
'pytest-benchmark[histogram]>=3.2.1',
|
|
|
|
]
|
|
|
|
|
|
|
|
Example
|
|
|
|
=======
|
|
|
|
|
|
|
|
This is a real-world example port of what `docker-compose`_ defines.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
[project]
|
|
|
|
dependencies = [
|
|
|
|
'cached-property >= 1.2.0, < 2',
|
|
|
|
'distro >= 1.5.0, < 2',
|
|
|
|
'docker[ssh] >= 4.2.2, < 5',
|
|
|
|
'dockerpty >= 0.4.1, < 1',
|
|
|
|
'docopt >= 0.6.1, < 1',
|
|
|
|
'jsonschema >= 2.5.1, < 4',
|
|
|
|
'PyYAML >= 3.10, < 6',
|
|
|
|
'python-dotenv >= 0.13.0, < 1',
|
|
|
|
'requests >= 2.20.0, < 3',
|
|
|
|
'texttable >= 0.9.0, < 2',
|
|
|
|
'websocket-client >= 0.32.0, < 1',
|
|
|
|
|
|
|
|
# Conditional
|
|
|
|
'backports.shutil_get_terminal_size == 1.0.0; python_version < "3.3"',
|
|
|
|
'backports.ssl_match_hostname >= 3.5, < 4; python_version < "3.5"',
|
|
|
|
'colorama >= 0.4, < 1; sys_platform == "win32"',
|
|
|
|
'enum34 >= 1.0.4, < 2; python_version < "3.4"',
|
|
|
|
'ipaddress >= 1.0.16, < 2; python_version < "3.3"',
|
|
|
|
'subprocess32 >= 3.5.4, < 4; python_version < "3.2"',
|
|
|
|
]
|
|
|
|
|
|
|
|
[project.optional-dependencies]
|
|
|
|
socks = [ 'PySocks >= 1.5.6, != 1.5.7, < 2' ]
|
|
|
|
tests = [
|
|
|
|
'ddt >= 1.2.2, < 2',
|
|
|
|
'pytest < 6',
|
|
|
|
'mock >= 1.0.1, < 4; python_version < "3.4"',
|
|
|
|
]
|
|
|
|
|
|
|
|
Copyright
|
|
|
|
=========
|
|
|
|
|
|
|
|
This document is placed in the public domain or under the
|
|
|
|
CC0-1.0-Universal license, whichever is more permissive.
|
|
|
|
|
|
|
|
|
|
|
|
.. _fields defined in PEP 621: https://www.python.org/dev/peps/pep-0621/#dependencies-optional-dependencies
|
|
|
|
.. _PEP 508 strings: https://www.python.org/dev/peps/pep-0508/
|
|
|
|
.. _Requires-Dist: https://packaging.python.org/specifications/core-metadata/#requires-dist-multiple-use
|
|
|
|
.. _Provides-Extra: https://packaging.python.org/specifications/core-metadata/#provides-extra-multiple-use
|
|
|
|
.. _docker-compose: https://github.com/docker/compose/blob/789bfb0e8b2e61f15f423d371508b698c64b057f/setup.py#L28-L61
|
|
|
|
|
|
|
|
..
|
|
|
|
Local Variables:
|
|
|
|
mode: indented-text
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
sentence-end-double-space: t
|
|
|
|
fill-column: 70
|
|
|
|
coding: utf-8
|
|
|
|
End:
|