[Distutils] FINAL DRAFT: Dependency specifier PEP

Robert Collins robertc at robertcollins.net
Tue Nov 17 18:21:03 EST 2015


Another hopefully last tweak - adding in more punctuation to the
strings in markers. I'm still holding off of defining \ escapes for
now.

-Rob

diff --git a/dependency-specification.rst b/dependency-specification.rst
index 8a632ba..b115b66 100644
--- a/dependency-specification.rst
+++ b/dependency-specification.rst
@@ -96,7 +96,9 @@ environments::

     marker_op     = version_cmp | (wsp* 'in') | (wsp* 'not' wsp+ 'in')
     python_str_c  = (wsp | letter | digit | '(' | ')' | '.' | '{' | '}' |
-                     '-' | '_' | '*')
+                     '-' | '_' | '*' | '#' | ':' | ';' | ',' | '/' | '?' |
+                     '[' | ']' | '!' | '~' | '`' | '@' | '$' | '%' | '^' |
+                     '&' | '=' | '+' | '|' | '<' | '>' )
     dquote        = '"'
     squote        = '\\''
     python_str    = (squote (python_str_c | dquote)* squote |
@@ -361,7 +363,9 @@ The complete parsley grammar::
     urlspec       = '@' wsp* <URI_reference>
     marker_op     = version_cmp | (wsp* 'in') | (wsp* 'not' wsp+ 'in')
     python_str_c  = (wsp | letter | digit | '(' | ')' | '.' | '{' | '}' |
-                     '-' | '_' | '*' | '#')
+                     '-' | '_' | '*' | '#' | ':' | ';' | ',' | '/' | '?' |
+                     '[' | ']' | '!' | '~' | '`' | '@' | '$' | '%' | '^' |
+                     '&' | '=' | '+' | '|' | '<' | '>' )
     dquote        = '"'
     squote        = '\\''
     python_str    = (squote <(python_str_c | dquote)*>:s squote |

On 18 November 2015 at 09:51, Robert Collins <robertc at robertcollins.net> wrote:
> Addressed along with some minor quirks and github feedback.
>
> diff --git a/dependency-specification.rst b/dependency-specification.rst
> index a9953ed..8a632ba 100644
> --- a/dependency-specification.rst
> +++ b/dependency-specification.rst
> @@ -18,7 +18,7 @@ Abstract
>  This PEP specifies the language used to describe dependencies for packages.
>  It draws a border at the edge of describing a single dependency - the
>  different sorts of dependencies and when they should be installed is a higher
> -level problem. The intent is provide a building block for higher layer
> +level problem. The intent is to provide a building block for higher layer
>  specifications.
>
>  The job of a dependency is to enable tools like pip [#pip]_ to find the right
> @@ -85,7 +85,7 @@ Versions may be specified according to the PEP-440
> [#pep440]_ rules. (Note:
>  URI is defined in std-66 [#std66]_::
>
>      version_cmp   = wsp* '<' | '<=' | '!=' | '==' | '>=' | '>' | '~=' | '==='
> -    version       = wsp* ( letterOrDigit | '-' | '_' | '.' | '*' )+
> +    version       = wsp* ( letterOrDigit | '-' | '_' | '.' | '*' | '+' | '!' )+
>      version_one   = version_cmp version wsp*
>      version_many  = version_one (wsp* ',' version_one)*
>      versionspec   = ( '(' version_many ')' ) | version_many
> @@ -94,7 +94,7 @@ URI is defined in std-66 [#std66]_::
>  Environment markers allow making a specification only take effect in some
>  environments::
>
> -    marker_op     = version_cmp | 'in' | 'not' wsp+ 'in'
> +    marker_op     = version_cmp | (wsp* 'in') | (wsp* 'not' wsp+ 'in')
>      python_str_c  = (wsp | letter | digit | '(' | ')' | '.' | '{' | '}' |
>                       '-' | '_' | '*')
>      dquote        = '"'
> @@ -108,10 +108,14 @@ environments::
>                       'implementation_name' | 'implementation_version' |
>                       'extra' # ONLY when defined by a containing layer
>                       )
> -    marker_var    = env_var | python_str
> -    marker_expr   = ('(' wsp* marker wsp* ')'
> -                     | (marker_var wsp* marker_op wsp* marker_var))
> -    marker        = wsp* marker_expr ( wsp* ('and' | 'or') wsp* marker_expr)*
> +    marker_var    = wsp* (env_var | python_str)
> +    marker_expr   = marker_var marker_op marker_var
> +                  | wsp* '(' marker wsp* ')'
> +    marker_and    = marker_expr wsp* 'and' marker_expr
> +                  | marker_expr
> +    marker_or     = marker_and wsp* 'or' marker_and
> +                      | marker_and
> +    marker        = marker_or
>      quoted_marker = ';' wsp* marker
>
>  Optional components of a distribution may be specified using the extras
> @@ -304,7 +308,7 @@ The ``implementation_version`` marker variable is
> derived from
>  Backwards Compatibility
>  =======================
>
> -Most of this PEP is already widely deployed and thus offers no compatibiltiy
> +Most of this PEP is already widely deployed and thus offers no compatibility
>  concerns.
>
>  There are however a few points where the PEP differs from the deployed base.
> @@ -355,7 +359,7 @@ The complete parsley grammar::
>      version_many  = version_one:v1 (wsp* ',' version_one)*:v2 -> [v1] + v2
>      versionspec   = ('(' version_many:v ')' ->v) | version_many
>      urlspec       = '@' wsp* <URI_reference>
> -    marker_op     = version_cmp | 'in' | 'not' wsp+ 'in'
> +    marker_op     = version_cmp | (wsp* 'in') | (wsp* 'not' wsp+ 'in')
>      python_str_c  = (wsp | letter | digit | '(' | ')' | '.' | '{' | '}' |
>                       '-' | '_' | '*' | '#')
>      dquote        = '"'
> @@ -369,12 +373,14 @@ The complete parsley grammar::
>                       'implementation_name' | 'implementation_version' |
>                       'extra' # ONLY when defined by a containing layer
>                       ):varname -> lookup(varname)
> -    marker_var    = env_var | python_str
> -    marker_expr   = (("(" wsp* marker:m wsp* ")" -> m)
> -                         | ((marker_var:l wsp* marker_op:o wsp* marker_var:r))
> -                         -> (l, o, r))
> -    marker        = (wsp* marker_expr:m ( wsp* ("and" | "or"):o wsp*
> -                     marker_expr:r -> (o, r))*:ms -> (m, ms))
> +    marker_var    = wsp* (env_var | python_str)
> +    marker_expr   = marker_var:l marker_op:o marker_var:r -> (o, l, r)
> +                  | wsp* '(' marker:m wsp* ')' -> m
> +    marker_and    = marker_expr:l wsp* 'and' marker_expr:r -> ('and', l, r)
> +                  | marker_expr:m -> m
> +    marker_or     = marker_and:l wsp* 'or' marker_and:r -> ('or', l, r)
> +                      | marker_and:m -> m
> +    marker        = marker_or
>      quoted_marker = ';' wsp* marker
>      identifier    = <letterOrDigit (
>                      letterOrDigit |
> @@ -469,8 +475,15 @@ A test program - if the grammar is in a string
> ``grammar``::
>          "name>=3,<2",
>          "name [fred,bar] @ http://foo.com ; python_version=='2.7'",
>          "name[quux, strange];python_version<'2.7' and platform_version=='2'",
> -        "name; os_name=='dud' and (os_name=='odd' or os_name=='fred')",
> -        "name; os_name=='dud' and os_name=='odd' or os_name=='fred'",
> +        "name; os_name=='a' or os_name=='b'",
> +        # Should parse as (a and b) or c
> +        "name; os_name=='a' and os_name=='b' or os_name=='c'",
> +        # Overriding precedence -> a and (b or c)
> +        "name; os_name=='a' and (os_name=='b' or os_name=='c')",
> +        # should parse as a or (b and c)
> +        "name; os_name=='a' or os_name=='b' and os_name=='c'",
> +        # Overriding precedence -> (a or b) and c
> +        "name; (os_name=='a' or os_name=='b') and os_name=='c'",
>          ]
>
>      def format_full_version(info):
> @@ -502,8 +515,8 @@ A test program - if the grammar is in a string ``grammar``::
>
>      compiled = makeGrammar(grammar, {'lookup': bindings.__getitem__})
>      for test in tests:
> -      parsed = compiled(test).specification()
> -      print(parsed)
> +        parsed = compiled(test).specification()
> +        print("%s -> %s" % (test, parsed))
>
>  References
>  ==========
>
> On 17 November 2015 at 16:59, Robert Collins <robertc at robertcollins.net> wrote:
>> On 17 November 2015 at 16:37, Nathaniel Smith <njs at pobox.com> wrote:
>>
>> Blah. Shall address.
>>
>> -Rob
>>
>>>
>>> --
>>> Nathaniel J. Smith -- http://vorpus.org
>>
>>
>>
>> --
>> Robert Collins <rbtcollins at hp.com>
>> Distinguished Technologist
>> HP Converged Cloud
>
>
>
> --
> Robert Collins <rbtcollins at hp.com>
> Distinguished Technologist
> HP Converged Cloud



-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud


More information about the Distutils-SIG mailing list