added the range operator, and more details on versions
This commit is contained in:
parent
3e07e8623b
commit
7fe3d72593
89
pep-0345.txt
89
pep-0345.txt
|
@ -283,15 +283,8 @@ optionally followed by a version declaration within parentheses.
|
||||||
The distutils project names should correspond to names as found
|
The distutils project names should correspond to names as found
|
||||||
on the `Python Package Index`_.
|
on the `Python Package Index`_.
|
||||||
|
|
||||||
A version declaration is a series of conditional operators and
|
Version declarations must follow the rules described in
|
||||||
version numbers, separated by commas. Conditional operators
|
`Version Specifiers`_
|
||||||
must be one of "<", ">", "<=", ">=", "==", and "!=". Version
|
|
||||||
numbers must be in the format specified in `PEP 386`_.
|
|
||||||
If no operator is provided with a version, the "==" operator
|
|
||||||
is used by default.
|
|
||||||
|
|
||||||
Any number of conditional operators can be specified, e.g.
|
|
||||||
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
|
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
|
|
||||||
|
@ -322,10 +315,9 @@ RDBMS bindings for use by a given ORM: each project might declare
|
||||||
that it provides ``ORM-bindings``, allowing other projects to depend
|
that it provides ``ORM-bindings``, allowing other projects to depend
|
||||||
only on having at most one of them installed.
|
only on having at most one of them installed.
|
||||||
|
|
||||||
A version declaration may be supplied (without a comparison
|
A version declaration may be supplied and must follow the rules described
|
||||||
operator); the distribution's version number will be implied if none
|
in `Version Specifiers`_. The distribution's version number will be implied
|
||||||
is specified. Version numbers must be in the format specified in
|
if none is specified.
|
||||||
`PEP 386`_.
|
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
|
|
||||||
|
@ -342,7 +334,7 @@ this package renders obsolete, meaning that the two packages
|
||||||
should not be installed at the same time.
|
should not be installed at the same time.
|
||||||
|
|
||||||
Version declarations can be supplied. Version numbers must be in the
|
Version declarations can be supplied. Version numbers must be in the
|
||||||
format specified in `PEP 386`_.
|
format specified in `Version Specifiers`_.
|
||||||
|
|
||||||
The most common use of this field will be in case a project name
|
The most common use of this field will be in case a project name
|
||||||
changes, e.g. Gorgon 2.3 gets subsumed into Torqued Python 1.0.
|
changes, e.g. Gorgon 2.3 gets subsumed into Torqued Python 1.0.
|
||||||
|
@ -359,19 +351,13 @@ Requires-Python
|
||||||
:::::::::::::::
|
:::::::::::::::
|
||||||
|
|
||||||
This field specifies the Python version(s) that the package is
|
This field specifies the Python version(s) that the package is
|
||||||
guaranteed to be compatible with. The format of the field is a
|
guaranteed to be compatible with.
|
||||||
series of conditional operators and version numbers, separated
|
|
||||||
by commas. Conditional operators must be one of "<", ">", "<=",
|
|
||||||
">=", "==", and "!=". If no operator is provided with a version,
|
|
||||||
the "==" operator is used by default.
|
|
||||||
|
|
||||||
Version numbers must be in the format specified in `PEP 386`_.
|
Version numbers must be in the format specified in `Version Specifiers`_.
|
||||||
|
|
||||||
Any number of conditional operators can be specified, e.g.
|
|
||||||
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
|
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
|
|
||||||
|
Requires-Python: 2.5
|
||||||
Requires-Python: >2.1
|
Requires-Python: >2.1
|
||||||
Requires-Python: >=2.3.4
|
Requires-Python: >=2.3.4
|
||||||
Requires-Python: 2.5, 2.6
|
Requires-Python: 2.5, 2.6
|
||||||
|
@ -389,19 +375,13 @@ The format of a requirement string is a name of an external
|
||||||
dependency, optionally followed by a version declaration within
|
dependency, optionally followed by a version declaration within
|
||||||
parentheses.
|
parentheses.
|
||||||
|
|
||||||
A version declaration is a series of conditional operators and
|
Version numbers must be in the format specified in `Version Specifiers`_.
|
||||||
version numbers, separated by commas. Conditional operators
|
|
||||||
must be one of "<", ">", "<=", ">=", "==", and "!=". If no
|
|
||||||
operator is provided with a version, the "==" operator is used by default.
|
|
||||||
|
|
||||||
Because they refer to non-Python software releases, version numbers
|
Because they refer to non-Python software releases, version numbers
|
||||||
for this field are **not** required to conform to the format
|
for this field are **not** required to conform to the format
|
||||||
specified in `PEP 386`_: they should correspond to the
|
specified in `PEP 386`_: they should correspond to the
|
||||||
version scheme used by the external dependency.
|
version scheme used by the external dependency.
|
||||||
|
|
||||||
Any number of conditional operators can be specified, e.g.
|
|
||||||
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
|
|
||||||
|
|
||||||
Notice that there's is no particular rule on the strings to be used.
|
Notice that there's is no particular rule on the strings to be used.
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
|
@ -426,8 +406,38 @@ The label is a free text limited to 32 signs.
|
||||||
Version Specifiers
|
Version Specifiers
|
||||||
==================
|
==================
|
||||||
|
|
||||||
The specification for distribution version specifiers has been moved to
|
Version specifiers are a series of conditional operators and
|
||||||
`PEP 386`_.
|
version numbers, separated by commas. Conditional operators
|
||||||
|
must be one of "<", ">", "<=", ">=", "==", "~=" and "!=".
|
||||||
|
|
||||||
|
Any number of conditional operators can be specified, e.g.
|
||||||
|
the string ``>1.0, !=1.3.4, <2.0`` is a legal version declaration.
|
||||||
|
The comma (``,``) is equivalent to the **or** operator.
|
||||||
|
|
||||||
|
Each version number must be in the format specified in `PEP 386`_.
|
||||||
|
|
||||||
|
The range operator ("~=") is a special operator that can be used to
|
||||||
|
define a range of versions by describing a MAJOR or a MAJOR.MINOR
|
||||||
|
version. All versions that starts with the definition will
|
||||||
|
be included in the range.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- ``Requires-Python: ~=2.5`` means all versions of Python 2.5.
|
||||||
|
- ``Requires-Python: ~=2`` means all versions of Python 2.
|
||||||
|
- ``~=2.5.2`` is equivalent to ``==2.5.2``
|
||||||
|
|
||||||
|
The range operator is limited to the MAJOR and MINOR parts of
|
||||||
|
a version string, as specified in `PEP 386`_. Post and pre-releases
|
||||||
|
are not included in range operators.
|
||||||
|
|
||||||
|
The ``Requires-External`` field can use the operators described in this
|
||||||
|
section but since the version scheme might not be compatible with `PEP 386`_,
|
||||||
|
the range operator might not be appliable.
|
||||||
|
|
||||||
|
For each field that uses a version, if no operator is provided, the
|
||||||
|
range operator is used by default. For example, ``Requires-Python: 2.5``
|
||||||
|
is equivalent to ``Requires-Python: ~=2.5``.
|
||||||
|
|
||||||
|
|
||||||
Environment markers
|
Environment markers
|
||||||
|
@ -445,17 +455,6 @@ Here are some example of fields using such markers::
|
||||||
Requires-Dist: bar; python_version == '2.4' or python_version == '2.5'
|
Requires-Dist: bar; python_version == '2.4' or python_version == '2.5'
|
||||||
Requires-External: libxslt; 'linux' in sys.platform
|
Requires-External: libxslt; 'linux' in sys.platform
|
||||||
|
|
||||||
These markers are using a micro-language that can be interpreted using a
|
|
||||||
function ``interpret_marker`` provided in the ``distutils.util`` module
|
|
||||||
in the stdlib::
|
|
||||||
|
|
||||||
>>> from distutils.util import interpret_marker
|
|
||||||
>>> interpret_marker("sys.platform == 'win32'")
|
|
||||||
True
|
|
||||||
|
|
||||||
Depending if the execution environment meets the requirements, the function
|
|
||||||
will return True or False.
|
|
||||||
|
|
||||||
The micro-language behind this is the simplest possible: it compares only
|
The micro-language behind this is the simplest possible: it compares only
|
||||||
strings, with the ``==`` and ``in`` operators (and their opposites), and
|
strings, with the ``==`` and ``in`` operators (and their opposites), and
|
||||||
with the ability to combine expressions. It makes it also easy to understand
|
with the ability to combine expressions. It makes it also easy to understand
|
||||||
|
@ -545,8 +544,8 @@ Acknowledgements
|
||||||
Fred Drake, Anthony Baxter and Matthias Klose have all contributed to
|
Fred Drake, Anthony Baxter and Matthias Klose have all contributed to
|
||||||
the ideas presented in this PEP.
|
the ideas presented in this PEP.
|
||||||
|
|
||||||
Tres Seaver, Jim Fulton, Marc-André Lemburg, Tarek Ziadé and other people at
|
Tres Seaver, Jim Fulton, Marc-André Lemburg, Martin von Löwis, Tarek Ziadé and
|
||||||
the Distutils-SIG have contributed to the new updated version.
|
other people at the Distutils-SIG have contributed to the new updated version.
|
||||||
|
|
||||||
|
|
||||||
..
|
..
|
||||||
|
|
Loading…
Reference in New Issue