Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
ignore = E203,W503,W504
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ matrix:
dist: xenial
- python: 3.8-dev
dist: xenial
- env: TOXENV=pep8
- python: 2.7
env: TOXENV=py2pep8
- env: TOXENV=lint
- env: TOXENV=docs
- env: TOXENV=packaging

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include CHANGELOG.rst CONTRIBUTING.rst README.rst
include LICENSE LICENSE.APACHE LICENSE.BSD

include .coveragerc
include .flake8
include tox.ini

recursive-include docs *
Expand Down
31 changes: 7 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
pygments_style = "sphinx"

extlinks = {
'issue': ('https://github.com/pypa/packaging/issues/%s', '#'),
'pull': ('https://github.com/pypa/packaging/pull/%s', 'PR #'),
"issue": ("https://github.com/pypa/packaging/issues/%s", "#"),
"pull": ("https://github.com/pypa/packaging/pull/%s", "PR #"),
}
# -- Options for HTML output --------------------------------------------------

Expand All @@ -87,34 +87,19 @@

# -- Options for LaTeX output -------------------------------------------------

latex_elements = {
}
latex_elements = {}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual])
latex_documents = [
(
"index",
"packaging.tex",
"Packaging Documentation",
"Donald Stufft",
"manual",
),
("index", "packaging.tex", "Packaging Documentation", "Donald Stufft", "manual")
]

# -- Options for manual page output -------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(
"index",
"packaging",
"Packaging Documentation",
["Donald Stufft"],
1,
)
]
man_pages = [("index", "packaging", "Packaging Documentation", ["Donald Stufft"], 1)]

# -- Options for Texinfo output -----------------------------------------------

Expand All @@ -130,12 +115,10 @@
"packaging",
"Core utilities for Python packages",
"Miscellaneous",
),
)
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"https://docs.python.org/": None,
}
intersphinx_mapping = {"https://docs.python.org/": None}

epub_theme = "epub"
9 changes: 5 additions & 4 deletions docs/development/submitting-patches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ follow the directions on the :doc:`security page </security>`.
Code
----

When in doubt, refer to :pep:`8` for Python code. You can check if your code
meets our automated requirements by running ``flake8`` against it. If you've
installed the development requirements this will automatically use our
configuration. You can also run the ``tox`` job with ``tox -e pep8``.
This project's source is auto-formatted with |black|. You can check if your
code meets our requirements by running our linters against it with ``tox -e
lint``.

`Write comments as complete sentences.`_

Expand Down Expand Up @@ -75,6 +74,8 @@ So, specifically:
* Use Sphinx parameter/attribute documentation `syntax`_.


.. |black| replace:: ``black``
.. _black: https://pypi.org/project/black/
.. _`Write comments as complete sentences.`: https://nedbatchelder.com/blog/201401/comments_should_be_sentences.html
.. _`syntax`: http://sphinx-doc.org/domains.html#info-field-lists
.. _`Studies have shown`: http://www.ibm.com/developerworks/rational/library/11-proven-practices-for-peer-review/
10 changes: 8 additions & 2 deletions packaging/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
from __future__ import absolute_import, division, print_function

__all__ = [
"__title__", "__summary__", "__uri__", "__version__", "__author__",
"__email__", "__license__", "__copyright__",
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
]

__title__ = "packaging"
Expand Down
20 changes: 16 additions & 4 deletions packaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
from __future__ import absolute_import, division, print_function

from .__about__ import (
__author__, __copyright__, __email__, __license__, __summary__, __title__,
__uri__, __version__
__author__,
__copyright__,
__email__,
__license__,
__summary__,
__title__,
__uri__,
__version__,
)

__all__ = [
"__title__", "__summary__", "__uri__", "__version__", "__author__",
"__email__", "__license__", "__copyright__",
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
]
7 changes: 4 additions & 3 deletions packaging/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# flake8: noqa

if PY3:
string_types = str,
string_types = (str,)
else:
string_types = basestring,
string_types = (basestring,)


def with_metaclass(meta, *bases):
Expand All @@ -27,4 +27,5 @@ def with_metaclass(meta, *bases):
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
return type.__new__(metaclass, 'temporary_class', (), {})

return type.__new__(metaclass, "temporary_class", (), {})
2 changes: 0 additions & 2 deletions packaging/_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Infinity(object):

def __repr__(self):
return "Infinity"

Expand Down Expand Up @@ -38,7 +37,6 @@ def __neg__(self):


class NegativeInfinity(object):

def __repr__(self):
return "-Infinity"

Expand Down
89 changes: 42 additions & 47 deletions packaging/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@


__all__ = [
"InvalidMarker", "UndefinedComparison", "UndefinedEnvironmentName",
"Marker", "default_environment",
"InvalidMarker",
"UndefinedComparison",
"UndefinedEnvironmentName",
"Marker",
"default_environment",
]


Expand All @@ -42,7 +45,6 @@ class UndefinedEnvironmentName(ValueError):


class Node(object):

def __init__(self, value):
self.value = value

Expand All @@ -57,62 +59,52 @@ def serialize(self):


class Variable(Node):

def serialize(self):
return str(self)


class Value(Node):

def serialize(self):
return '"{0}"'.format(self)


class Op(Node):

def serialize(self):
return str(self)


VARIABLE = (
L("implementation_version") |
L("platform_python_implementation") |
L("implementation_name") |
L("python_full_version") |
L("platform_release") |
L("platform_version") |
L("platform_machine") |
L("platform_system") |
L("python_version") |
L("sys_platform") |
L("os_name") |
L("os.name") | # PEP-345
L("sys.platform") | # PEP-345
L("platform.version") | # PEP-345
L("platform.machine") | # PEP-345
L("platform.python_implementation") | # PEP-345
L("python_implementation") | # undocumented setuptools legacy
L("extra")
L("implementation_version")
| L("platform_python_implementation")
| L("implementation_name")
| L("python_full_version")
| L("platform_release")
| L("platform_version")
| L("platform_machine")
| L("platform_system")
| L("python_version")
| L("sys_platform")
| L("os_name")
| L("os.name")
| L("sys.platform") # PEP-345
| L("platform.version") # PEP-345
| L("platform.machine") # PEP-345
| L("platform.python_implementation") # PEP-345
| L("python_implementation") # PEP-345
| L("extra") # undocumented setuptools legacy
)
ALIASES = {
'os.name': 'os_name',
'sys.platform': 'sys_platform',
'platform.version': 'platform_version',
'platform.machine': 'platform_machine',
'platform.python_implementation': 'platform_python_implementation',
'python_implementation': 'platform_python_implementation'
"os.name": "os_name",
"sys.platform": "sys_platform",
"platform.version": "platform_version",
"platform.machine": "platform_machine",
"platform.python_implementation": "platform_python_implementation",
"python_implementation": "platform_python_implementation",
}
VARIABLE.setParseAction(lambda s, l, t: Variable(ALIASES.get(t[0], t[0])))

VERSION_CMP = (
L("===") |
L("==") |
L(">=") |
L("<=") |
L("!=") |
L("~=") |
L(">") |
L("<")
L("===") | L("==") | L(">=") | L("<=") | L("!=") | L("~=") | L(">") | L("<")
)

MARKER_OP = VERSION_CMP | L("not in") | L("in")
Expand Down Expand Up @@ -152,8 +144,11 @@ def _format_marker(marker, first=True):
# where the single item is itself it's own list. In that case we want skip
# the rest of this function so that we don't get extraneous () on the
# outside.
if (isinstance(marker, list) and len(marker) == 1 and
isinstance(marker[0], (list, tuple))):
if (
isinstance(marker, list)
and len(marker) == 1
and isinstance(marker[0], (list, tuple))
):
return _format_marker(marker[0])

if isinstance(marker, list):
Expand Down Expand Up @@ -239,20 +234,20 @@ def _evaluate_markers(markers, environment):


def format_full_version(info):
version = '{0.major}.{0.minor}.{0.micro}'.format(info)
version = "{0.major}.{0.minor}.{0.micro}".format(info)
kind = info.releaselevel
if kind != 'final':
if kind != "final":
version += kind[0] + str(info.serial)
return version


def default_environment():
if hasattr(sys, 'implementation'):
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = '0'
implementation_name = ''
iver = "0"
implementation_name = ""

return {
"implementation_name": implementation_name,
Expand All @@ -270,13 +265,13 @@ def default_environment():


class Marker(object):

def __init__(self, marker):
try:
self._markers = _coerce_parse_result(MARKER.parseString(marker))
except ParseException as e:
err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
marker, marker[e.loc:e.loc + 8])
marker, marker[e.loc : e.loc + 8]
)
raise InvalidMarker(err_str)

def __str__(self):
Expand Down
Loading