-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
brettcannon
merged 57 commits into
python:master
from
EpicWink:pep-621-exploded-dependencies
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 5834a79
Remove requirement-table reference
EpicWink 73f8042
Fix email
EpicWink 1725ae4
Add note on why markers weren't split
EpicWink 8f8a5ac
Add depenencies-array to rejected ideas
EpicWink bad0a73
Switch to 'direct' table for direct references
EpicWink ecd83f5
Fix incorrect 'version' keys in example
EpicWink 5e021c1
Add motivation to contrast with the PEP-508 string implementation
EpicWink 9714036
Add open-issue note on environment-marker keys
EpicWink d9c0264
Add open-issue notes on removing 'optional-dependencies' table
EpicWink df0f106
Fix 'pip' keys in standard-table example
EpicWink da510f9
Fix dependencies key name in examples
EpicWink c3493a0
Allow version specifiers as requirement specifiers
EpicWink 2a05613
Include more arguments against separate 'revision' field
EpicWink ea97aed
Reject alternate definitions of extra requirements
EpicWink 3f7daaa
Make note about 'file' protocol for direct requirements
EpicWink 1fd5245
Show consistent examples
EpicWink bdd34f5
Add example implementation for conversion to PEP 508
EpicWink 60d194d
Syntax highlighting (#1)
pradyunsg 70f6c9b
Cleanup TOML example snippets (#2)
abn 471960e
Move direct-reference keys to top-level
EpicWink 77f6420
Re-open 'for-extra' key issue
EpicWink aafed71
Remove hash from requirement
EpicWink aa1b287
Add work-around for environment marker keys drawback
EpicWink bd29e2d
Allow empty string to for any-version
EpicWink 375aea5
Allow environment markers as keys (#5)
EpicWink 16e65a6
Revert "Allow environment markers as keys (#5)"
EpicWink ffb0dad
Defer the environment marker keys idea
EpicWink 22741e4
Convert optional-deps to table of reqs with extra key (#4)
EpicWink febb954
Add PEP 508 compatibility examples (#3)
abn a69fa93
Typo fix, indentation as spaces
EpicWink d742168
Fix example conversion for 'for-extra' key
EpicWink 109d4e8
Improve note on multiple requirements for the same project
EpicWink 9266677
Remove note on environment marker keys in rationale (already in rejec…
EpicWink 2bfad0f
Note requirement keys are optional
EpicWink 5531d87
Add optional dependencies to full example
EpicWink b91ce23
Merge remote-tracking branch 'upstream/master' into pep-621-exploded-…
EpicWink 4f3f366
Explicitly only allow URLs for VCS repository paths
EpicWink 0c18b61
Remove syntax highlighting
EpicWink 2389765
Remove post-history
EpicWink ec974b7
Add Arun to authors
EpicWink 6580e7a
Assign PEP number 633
EpicWink 74ea833
Add Brett as sponsor, set discussions link
EpicWink 0b7e2ac
Set post history
EpicWink a795290
Update created date format
EpicWink 92df91d
Remove specific mention on which tables are defined
EpicWink 6e97975
Format TOML mentions in all-caps
EpicWink d493d65
Code-format table-name headings
EpicWink f7191f8
Use RF 2119 language
EpicWink 63fea79
Typo fix
EpicWink e61c423
Explicitly re-mention empty-string as no constraint
EpicWink f5ee3bc
Mark first example as artificial
EpicWink 246bf03
Changes rejected-ideas list to subsections
EpicWink 62bd3e0
Improve definition of 'for-extra'
EpicWink d3c7970
Add note on unknown keys
EpicWink 7ebe5b1
Update wording on table names in PEP 621
EpicWink ef0d461
Rename to PEP 633
EpicWink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "Allow environment markers as keys (#5)"
This reverts commit 375aea5.
- Loading branch information
commit 16e65a6397248e5a94a813c66e1481f6dbf3cd9c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -139,26 +140,6 @@ logically conflict with each other in the requirement: ``version``, ``url``, | |
|
||
An empty requirement table ``{}`` places no restriction on the requirement. | ||
|
||
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 | ||
--------------------- | ||
|
||
|
@@ -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 | ||
|
||
|
||
|
@@ -253,13 +209,13 @@ Full example: | |
[project.dependencies] | ||
flask = { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this preferred over the empty string? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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" } | ||
|
@@ -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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.