From 6c1a8ea332b8482e17fdcced61f97aa7b203dcd9 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Aug 2020 15:03:18 -0400 Subject: [PATCH 01/11] PEP 631: Dependency specification in pyproject.toml --- pep-0631.rst | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 pep-0631.rst diff --git a/pep-0631.rst b/pep-0631.rst new file mode 100644 index 00000000000..7c38e959591 --- /dev/null +++ b/pep-0631.rst @@ -0,0 +1,148 @@ +PEP: 631 +Title: Dependency specification in pyproject.toml +Author: Ofek Lev +Discussions-To: https://discuss.python.org/t/pep-631-dependency-specification-in-pyproject-toml/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. + +.. code-block:: python + + from packaging.requirements import InvalidRequirement, Requirement + + ... + + try: + Requirement(entry) + except InvalidRequirement: + # exit + +Specification +============= + +dependencies +------------ + +- Format: array of strings, or inline table +- Related core metadata: + + - `Requires-Dist`_ + +If the field is an array, every element must be an `entry <#entries>`_. + +.. code-block:: toml + + [project] + dependencies = [ + 'PyYAML ~= 5', + 'requests[security] < 3', + 'subprocess32; python_version < "3.2"', + ] + +If the field is a table, the ``file`` key has a string value representing a +relative path to a file containing at most one `entry <#entries>`_ per line. +Backends MUST ignore empty lines and lines starting with comments (``#``). + +.. code-block:: toml + + [project] + dependencies = { file = 'requirements.txt' } + +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 +the `dependencies <#dependencies>`_ field i.e. an array of strings or an inline table. + +.. code-block:: toml + + [project.optional-dependencies] + spam = { file = 'features/spam.txt' } + 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. + +.. code-block:: toml + + [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: From e9ddd6ddad7b318ea4a0561aba63a7f941098299 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Aug 2020 16:16:27 -0400 Subject: [PATCH 02/11] update ci deps --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2632a6fba6..5fe0cf901a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ dist: xenial cache: pip before_install: - - pip install docutils + - pip install docutils pygments script: - make -j$(nproc) From a3001276395ad31bbbb8ec46c494d85f828b401a Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Aug 2020 17:16:32 -0400 Subject: [PATCH 03/11] fix compatible release clause example --- pep-0631.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0631.rst b/pep-0631.rst index 7c38e959591..b60f4328790 100644 --- a/pep-0631.rst +++ b/pep-0631.rst @@ -51,7 +51,7 @@ If the field is an array, every element must be an `entry <#entries>`_. [project] dependencies = [ - 'PyYAML ~= 5', + 'PyYAML ~= 5.0', 'requests[security] < 3', 'subprocess32; python_version < "3.2"', ] From 7f3ad7bf95d59d1674359f5ed6e397d85ed986d6 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Aug 2020 17:22:13 -0400 Subject: [PATCH 04/11] rename --- pep-0631.rst => pep-0999.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pep-0631.rst => pep-0999.rst (99%) diff --git a/pep-0631.rst b/pep-0999.rst similarity index 99% rename from pep-0631.rst rename to pep-0999.rst index b60f4328790..757ae0479b1 100644 --- a/pep-0631.rst +++ b/pep-0999.rst @@ -1,4 +1,4 @@ -PEP: 631 +PEP: 999 Title: Dependency specification in pyproject.toml Author: Ofek Lev Discussions-To: https://discuss.python.org/t/pep-631-dependency-specification-in-pyproject-toml/5018 From 100d0eb02746e023ed9ec1fa66b4c437817d5db0 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 20 Aug 2020 18:09:14 -0400 Subject: [PATCH 05/11] fix title too --- pep-0999.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0999.rst b/pep-0999.rst index 757ae0479b1..0df99aff7cc 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -1,7 +1,7 @@ PEP: 999 -Title: Dependency specification in pyproject.toml +Title: Dependency specification in pyproject.toml based on PEP 508 Author: Ofek Lev -Discussions-To: https://discuss.python.org/t/pep-631-dependency-specification-in-pyproject-toml/5018 +Discussions-To: https://discuss.python.org/t/pep-999-dependency-specification-in-pyproject-toml-based-on-pep-508/5018 Status: Draft Type: Standards Track Content-Type: text/x-rst From 992fa266e2bd043cc9f6e171e6ea72228e956261 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 11:21:38 -0400 Subject: [PATCH 06/11] add sponsor --- pep-0999.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/pep-0999.rst b/pep-0999.rst index 0df99aff7cc..c5645d9dea1 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -1,6 +1,7 @@ PEP: 999 Title: Dependency specification in pyproject.toml based on PEP 508 Author: Ofek Lev +Sponsor: Paul Ganssle Discussions-To: https://discuss.python.org/t/pep-999-dependency-specification-in-pyproject-toml-based-on-pep-508/5018 Status: Draft Type: Standards Track From 5e65e416bd9dff39f4a22553ffb13ac5f7445402 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 16:21:59 -0400 Subject: [PATCH 07/11] remove code highlighting --- .travis.yml | 2 +- pep-0999.rst | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5fe0cf901a1..a2632a6fba6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ dist: xenial cache: pip before_install: - - pip install docutils pygments + - pip install docutils script: - make -j$(nproc) diff --git a/pep-0999.rst b/pep-0999.rst index c5645d9dea1..b682b3fa466 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -24,7 +24,7 @@ All dependency entries MUST be valid `PEP 508 strings`_. Build backends SHOULD abort at load time for any parsing errors. -.. code-block:: python +:: from packaging.requirements import InvalidRequirement, Requirement @@ -48,7 +48,7 @@ dependencies If the field is an array, every element must be an `entry <#entries>`_. -.. code-block:: toml +:: [project] dependencies = [ @@ -61,7 +61,7 @@ If the field is a table, the ``file`` key has a string value representing a relative path to a file containing at most one `entry <#entries>`_ per line. Backends MUST ignore empty lines and lines starting with comments (``#``). -.. code-block:: toml +:: [project] dependencies = { file = 'requirements.txt' } @@ -78,7 +78,7 @@ optional-dependencies Each key is the name of the provided option, with each value being the same type as the `dependencies <#dependencies>`_ field i.e. an array of strings or an inline table. -.. code-block:: toml +:: [project.optional-dependencies] spam = { file = 'features/spam.txt' } @@ -93,7 +93,7 @@ Example This is a real-world example port of what `docker-compose`_ defines. -.. code-block:: toml +:: [project] dependencies = [ From 5ffd77a898832fd99987e5dec1a5517393b7a2be Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 16:56:42 -0400 Subject: [PATCH 08/11] remove file option for now --- pep-0999.rst | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pep-0999.rst b/pep-0999.rst index b682b3fa466..80b870b60e4 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -41,12 +41,12 @@ Specification dependencies ------------ -- Format: array of strings, or inline table +- Format: array of strings - Related core metadata: - `Requires-Dist`_ -If the field is an array, every element must be an `entry <#entries>`_. +Every element must be an `entry <#entries>`_. :: @@ -57,15 +57,6 @@ If the field is an array, every element must be an `entry <#entries>`_. 'subprocess32; python_version < "3.2"', ] -If the field is a table, the ``file`` key has a string value representing a -relative path to a file containing at most one `entry <#entries>`_ per line. -Backends MUST ignore empty lines and lines starting with comments (``#``). - -:: - - [project] - dependencies = { file = 'requirements.txt' } - optional-dependencies --------------------- @@ -76,12 +67,11 @@ optional-dependencies - `Requires-Dist`_ Each key is the name of the provided option, with each value being the same type as -the `dependencies <#dependencies>`_ field i.e. an array of strings or an inline table. +the `dependencies <#dependencies>`_ field i.e. an array of strings. :: [project.optional-dependencies] - spam = { file = 'features/spam.txt' } tests = [ 'coverage>=5.0.3', 'pytest', From 1034af33933ff5874619f34a72e6fb30a4f10278 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 17:14:44 -0400 Subject: [PATCH 09/11] Apply suggestions from code review Co-authored-by: Paul Ganssle --- pep-0999.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0999.rst b/pep-0999.rst index 80b870b60e4..89516614167 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -2,7 +2,7 @@ PEP: 999 Title: Dependency specification in pyproject.toml based on PEP 508 Author: Ofek Lev Sponsor: Paul Ganssle -Discussions-To: https://discuss.python.org/t/pep-999-dependency-specification-in-pyproject-toml-based-on-pep-508/5018 +Discussions-To: https://discuss.python.org/t/5018 Status: Draft Type: Standards Track Content-Type: text/x-rst From a48a6ded4fbbf8baeb645eec14dd0a4beae28705 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 17:15:19 -0400 Subject: [PATCH 10/11] finalize PEP number --- pep-0999.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0999.rst b/pep-0999.rst index 89516614167..962f1eb53b9 100644 --- a/pep-0999.rst +++ b/pep-0999.rst @@ -1,4 +1,4 @@ -PEP: 999 +PEP: 631 Title: Dependency specification in pyproject.toml based on PEP 508 Author: Ofek Lev Sponsor: Paul Ganssle From 76b59e0fd61b565de27cc7be8a17372c0832014b Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 17:15:51 -0400 Subject: [PATCH 11/11] rename file --- pep-0999.rst => pep-0631.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pep-0999.rst => pep-0631.rst (100%) diff --git a/pep-0999.rst b/pep-0631.rst similarity index 100% rename from pep-0999.rst rename to pep-0631.rst