8000 PEP 633: Exploded dependencies for PEP 621 by EpicWink · Pull Request #1595 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

PEP 633: Exploded dependencies for PEP 621 #1595

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 57 commits into from
Sep 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
90bc912
Add initial exploded-dependencies spec for PEP-621 PEP
EpicWink Sep 2, 2020
5834a79
Remove requirement-table reference
EpicWink Sep 2, 2020
73f8042
Fix email
EpicWink Sep 2, 2020
1725ae4
Add note on why markers weren't split
EpicWink Sep 3, 2020
8f8a5ac
Add depenencies-array to rejected ideas
EpicWink Sep 3, 2020
bad0a73
Switch to 'direct' table for direct references
EpicWink Sep 3, 2020
ecd83f5
Fix incorrect 'version' keys in example
EpicWink Sep 3, 2020
5e021c1
Add motivation to contrast with the PEP-508 string implementation
EpicWink Sep 3, 2020
9714036
Add open-issue note on environment-marker keys
EpicWink Sep 3, 2020
d9c0264
Add open-issue notes on removing 'optional-dependencies' table
EpicWink Sep 3, 2020
df0f106
Fix 'pip' keys in standard-table example
EpicWink Sep 3, 2020
da510f9
Fix dependencies key name in examples
EpicWink Sep 3, 2020
c3493a0
Allow version specifiers as requirement specifiers
EpicWink Sep 6, 2020
2a05613
Include more arguments against separate 'revision' field
EpicWink Sep 6, 2020
ea97aed
Reject alternate definitions of extra requirements
EpicWink Sep 6, 2020
3f7daaa
Make note about 'file' protocol for direct requirements
EpicWink Sep 6, 2020
1fd5245
Show consistent examples
EpicWink Sep 6, 2020
bdd34f5
Add example implementation for conversion to PEP 508
EpicWink Sep 6, 2020
60d194d
Syntax highlighting (#1)
pradyunsg Sep 7, 2020
70f6c9b
Cleanup TOML example snippets (#2)
abn Sep 7, 2020
471960e
Move direct-reference keys to top-level
EpicWink Sep 7, 2020
77f6420
Re-open 'for-extra' key issue
EpicWink Sep 8, 2020
aafed71
Remove hash from requirement
EpicWink Sep 8, 2020
aa1b287
Add work-around for environment marker keys drawback
EpicWink Sep 8, 2020
bd29e2d
Allow empty string to for any-version
EpicWink Sep 8, 2020
375aea5
Allow environment markers as keys (#5)
EpicWink Sep 9, 2020
16e65a6
Revert "Allow environment markers as keys (#5)"
EpicWink Sep 9, 2020
ffb0dad
Defer the environment marker keys idea
EpicWink Sep 9, 2020
22741e4
Convert optional-deps to table of reqs with extra key (#4)
EpicWink Sep 9, 2020
febb954
Add PEP 508 compatibility examples (#3)
abn Sep 9, 2020
a69fa93
Typo fix, indentation as spaces
EpicWink Sep 9, 2020
d742168
Fix example conversion for 'for-extra' key
EpicWink Sep 9, 2020
109d4e8
Improve note on multiple requirements for the same project
EpicWink Sep 9, 2020
9266677
Remove note on environment marker keys in rationale (already in rejec…
EpicWink Sep 9, 2020
2bfad0f
Note requirement keys are optional
EpicWink Sep 9, 2020
5531d87
Add optional dependencies to full example
EpicWink Sep 9, 2020
b91ce23
Merge remote-tracking branch 'upstream/master' into pep-621-exploded-…
EpicWink Sep 10, 2020
4f3f366
Explicitly only allow URLs for VCS repository paths
EpicWink Sep 10, 2020
0c18b61
Remove syntax highlighting
EpicWink Sep 10, 2020
2389765
Remove post-history
EpicWink Sep 10, 2020
ec974b7
Add Arun to authors
EpicWink Sep 10, 2020
6580e7a
Assign PEP number 633
EpicWink Sep 12, 2020
74ea833
Add Brett as sponsor, set discussions link
EpicWink Sep 12, 2020
0b7e2ac
Set post history
EpicWink Sep 12, 2020
a795290
Update created date format
EpicWink Sep 12, 2020
92df91d
Remove specific mention on which tables are defined
EpicWink Sep 12, 2020
6e97975
Format TOML mentions in all-caps
EpicWink Sep 12, 2020
d493d65
Code-format table-name headings
EpicWink Sep 12, 2020
f7191f8
Use RF 2119 language
EpicWink Sep 12, 2020
63fea79
Typo fix
EpicWink Sep 12, 2020
e61c423
Explicitly re-mention empty-string as no constraint
EpicWink Sep 12, 2020
f5ee3bc
Mark first example as artificial
EpicWink Sep 12, 2020
246bf03
Changes rejected-ideas list to subsections
EpicWink Sep 12, 2020
62bd3e0
Improve definition of 'for-extra'
EpicWink Sep 12, 2020
d3c7970
Add note on unknown keys
EpicWink Sep 12, 2020
7ebe5b1
Update wording on table names in PEP 621
EpicWink Sep 12, 2020
ef0d461
Rename to PEP 633
EpicWink Sep 12, 2020
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
Prev Previous commit
Next Next commit
Revert "Allow environment markers as keys (#5)"
This reverts commit 375aea5.
  • Loading branch information
EpicWink committed Sep 9, 2020
commit 16e65a6397248e5a94a813c66e1481f6dbf3cd9c
88 changes: 22 additions & 66 deletions pep-9999.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ between this format and :pep:`508`-style specifiers.
One example is the need to allow for specifying distributions in multiple
dependencies (environment markers will choose the appropriate dependency).

The environment markers are modelled from `Poetry`_ and `Pipfile`_, and the
ability to specify environment markers in keys was allowed due to the
improved ease-of-use. The decision to convert underscores ``_`` to hyphens
``-`` was made to keep keys consistent with the rest of :pep:`621`.
Some dependency specifications, as in `Poetry`_, separate the :pep:`508`
environment markers into separate keys in the requirement. This loses the
general Python-like syntax for environment markers, and also removes the
ability to logically combines the markers with grouped `and` and `or`
operations.

The direct-reference keys closely align with and utilise pep:`610` and
:pep:`440` as to reduce differences in the packaging ecosystem and rely on
Expand Down Expand Up @@ -139,26 +140,6 @@ logically conflict with each other in the requirement: ``version``, ``url``,

An empty requirement table ``{}`` places no restriction on the requirement.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be equivalent to the empty string? So there's two ways to list a dependency with no restrictions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The empty string (or the string "*") was fairly heavily pushed for as placing no constraint, while there was no comment on the empty table. What's worse is that the empty array is not allowed. This is something to bring up in the discussion.


Environment markers
*******************

All of the :pep:`508` environment marker variables are allowed as keys in the
requirement table, with underscores ``_`` replace with hyphens ``-``. The
values are strings which consitute the remainder of the environment marker.

As an example, for the environment marker ``python_version < "2.7"``, the
following is included in the requirement table:

.. code-block:: toml

python-version = "< '2.7'"

All of these environment markers must be satisfied, in addition to the value of
the ``markers`` key, for a requirement to be included.

The ``extra`` marker must not be confused with the ``extras`` key defined
above.

optional-dependencies
---------------------

Expand Down Expand Up @@ -194,33 +175,8 @@ performed):
pep508 += " @ " + vcs + "+" requirement[vcs]
if "revision" in requirement:
pep508 += "@" + revision
markers = ""
for variable in (
"os_name",
"sys_platform",
"platform_machine",
"platform_python_implementation",
"platform_release",
"platform_system",
"platform_version",
"python_version",
"python_full_version",
"implementation_name",
"implementation_version",
"extra",
):
key = variable.replace("_", "-")
if key in requirement:
if markers:
markers += " and "
markers += variable + " " + requirement[key]
if "markers" in requirement:
markers_explicit = requirement["markers"]
if markers:
markers_explicit = " and (" + markers_explicit + ")"
markers += markers_explicit
if markers:
pep508 += " ; " + markers
pep508 += "; " + requirement["markers"]
return pep508


Expand Down Expand Up @@ -253,13 +209,13 @@ Full example:
[project.dependencies]
flask = { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this preferred over the empty string?

Copy link
Contributor Author
@EpicWink EpicWink Sep 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference. I'll ask the discussion on this

django = { }
requests = { version = ">= 2.8.1, == 2.8.*", extras = ["security", "tests"], python-version = "< '2.7'" }
requests = { version = ">= 2.8.1, == 2.8.*", extras = ["security", "tests"], markers = "python_version < '2.7'" }
pip = { url = "https://github.com/pypa/pip/archive/1.3.1.zip" }
sphinx = { git = "ssh://git@github.com/sphinx-doc/sphinx.git" }
numpy = "~=1.18"
pytest = [
{ version = "<6", python-version = "< '3.5'" },
{ version = ">=6", python-version = ">= '3.5'" },
{ version = "<6", markers = "python_version < '3.5'" },
{ version = ">=6", markers = "python_version >= '3.5'" },
]

In homage to :pep:`631`, the following is an equivalent dependencies
Expand All @@ -280,12 +236,12 @@ specification for `docker-compose`_:
websocket-client = ">= 0.32.0, < 1"

# Conditional
"backports.shutil_get_terminal_size" = { version = "== 1.0.0", python-version = "< '3.3'" }
"backports.ssl_match_hostname" = { version = ">= 3.5, < 4", python-version = "< '3.5'" }
colorama = { version = ">= 0.4, < 1", sys-platform = "== 'win32'" }
enum34 = { version = ">= 1.0.4, < 2", python-version = "< '3.4'" }
ipaddress = { version = ">= 1.0.16, < 2", python-version = "< '3.3'" }
subprocess32 = { version = ">= 3.5.4, < 4", python-version = "< '3.2'" }
"backports.shutil_get_terminal_size" = { version = "== 1.0.0", markers = "python_version < '3.3'" }
"backports.ssl_match_hostname" = { version = ">= 3.5, < 4", markers = "python_version < '3.5'" }
colorama = { version = ">= 0.4, < 1", markers = "sys_platform == 'win32'" }
enum34 = { version = ">= 1.0.4, < 2", markers = "python_version < '3.4'" }
ipaddress = { version = ">= 1.0.16, < 2", markers = "python_version < '3.3'" }
subprocess32 = { version = ">= 3.5.4, < 4", markers = "python_version < '3.2'" }

[project.optional-dependencies.socks]
PySocks = { version = ">= 1.5.6, != 1.5.7, < 2" }
Expand Down Expand Up @@ -325,17 +281,17 @@ Rejected Ideas
- Include hash in direct-reference requirements. This was only for package
lock-files, and didn't really have a place in the project's metadata.

- Only allowing environment markers in ``markers`` key. The environment marker
keys allows for increases in readability and ease of parsing for common
cases, with no major drawbacks.


Open Issues
===========

- Prefixing all environment-marker keys with ``if-``. This increases verbosity,
but makes environment-markers less likely to conflict with future keys and
better states the intention of these keys.
- Making each :pep:`508` environment marker as a key (or child-table key) in
the requirement. This arguably increases readability and ease of parsing,
however the ability to have nested groups of ``and`` and ``or`` operations
on the markers is lost.

A solution to this is to still allow the ``markers`` key, with which the
key-specified environment markers and ``and``'d with the result of.

- Including a required ``for-extra`` key in extra requirements, which specifies
the extra for which the requirement is required for. This allows the
Expand Down
0