Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0f9d259
Add basic mypy support
pradyunsg Jun 14, 2017
bc637a8
:newspaper:
pradyunsg Jun 16, 2017
ed9208e
Improve mypy configuration
pradyunsg Jun 14, 2017
9fce241
Patch pkg_resources for mypy
pradyunsg Jun 15, 2017
8f92b55
Fix mypy warnings
pradyunsg Jun 15, 2017
da46ab2
Add type annotations to pip.configuration
pradyunsg Jun 15, 2017
711596b
Use pip.utils.typing to guard typing imports
pradyunsg Jun 16, 2017
7c5f901
Modify vendoring to include additional .pyi stubs
pradyunsg Jul 4, 2017
adf4538
Add generated stubs
pradyunsg Jul 4, 2017
c2371a1
Exclude the pyi files and extra directory created
pradyunsg Jul 4, 2017
b3e16f9
Fix mypy errors since addition of stubs
pradyunsg Jul 17, 2017
55fd83f
Add a separate tox job for mypy
pradyunsg Jul 17, 2017
6a0da3d
Fix a bug found by mypy
pradyunsg Jul 17, 2017
9b03434
use six instead of try except
pradyunsg Jul 17, 2017
3046f7a
Don't ask for permission
pradyunsg Jul 17, 2017
182c548
Fix remaining errors
pradyunsg Jul 17, 2017
b9b5e4a
:art:
pradyunsg Jul 17, 2017
1b5a23f
:wrench:
pradyunsg Jul 17, 2017
c365304
Merge branch 'master' into mypy/infrastructure
pradyunsg Aug 2, 2017
cb113d5
I actually missed a conflict. Wow.
pradyunsg Aug 2, 2017
11451c5
Merge branch 'master' into mypy/infrastructure
pradyunsg Sep 2, 2017
d37868f
Move the typing file
pradyunsg Sep 2, 2017
d408818
Add imports I'd missed
pradyunsg Sep 2, 2017
d9a4431
Move mypy stubs as well
pradyunsg Sep 2, 2017
efd7264
Update MANIFEST
pradyunsg Sep 2, 2017
ec26f0a
Import from inner packages
pradyunsg Sep 2, 2017
da57810
type: Any partials in cmdoptions
pradyunsg Sep 2, 2017
93d9f20
Remove a useless section
pradyunsg Sep 2, 2017
e2b2f70
isort all imports
pradyunsg Sep 2, 2017
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
Merge branch 'master' into mypy/infrastructure
  • Loading branch information
pradyunsg committed Aug 2, 2017
commit c365304f66ac9e87a02f854f81e6e280ccaf16ad
42 changes: 18 additions & 24 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ Installation
Do I need to install pip?
-------------------------

pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4
binaries downloaded from `python.org <https://www.python.org>`_, but you'll
need to :ref:`upgrade pip <Upgrading pip>`.

Additionally, pip will already be installed if you're working in a :ref:`Virtual
Environment <pypug:Creating and using Virtual Environments>` created by
:ref:`pypug:virtualenv` or :ref:`pyvenv <pypug:venv>`.
pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4
downloaded from `python.org <https://www.python.org>`_ or if you are working
in a :ref:`Virtual Environment <pypug:Creating and using Virtual Environments>`
created by :ref:`pypug:virtualenv` or :ref:`pyvenv <pypug:venv>`.
Just make sure to :ref:`upgrade pip <Upgrading pip>`.


.. _`get-pip`:
Expand All @@ -21,25 +19,25 @@ Installing with get-pip.py
--------------------------

To install pip, securely download `get-pip.py
<https://bootstrap.pypa.io/get-pip.py>`_. [1]_
<https://bootstrap.pypa.io/get-pip.py>`_. [1]_::

Then run the following:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

::
Inspect ``get-pip.py`` for any malevolence. Then run the following::

python get-pip.py


.. warning::

Be cautious if you're using a Python install that's managed by your operating
system or another package manager. get-pip.py does not coordinate with
Be cautious if you are using a Python install that is managed by your operating
system or another package manager. ``get-pip.py`` does not coordinate with
those tools, and may leave your system in an inconsistent state.

get-pip.py will also install :ref:`pypug:setuptools` [2]_ and :ref:`pypug:wheel`,
if they're not already. :ref:`pypug:setuptools` is required to install
``get-pip.py`` also installs :ref:`pypug:setuptools` [2]_ and :ref:`pypug:wheel`
if they are not already. :ref:`pypug:setuptools` is required to install
:term:`source distributions <pypug:Source Distribution (or "sdist")>`. Both are
required to be able to build a :ref:`Wheel cache` (which improves installation
required in order to build a :ref:`Wheel cache` (which improves installation
speed), although neither are required to install pre-built :term:`wheels
<pypug:Wheel>`.

Expand All @@ -55,14 +53,14 @@ get-pip.py options

.. option:: --no-setuptools

If set, don't attempt to install :ref:`pypug:setuptools`
If set, do not attempt to install :ref:`pypug:setuptools`

.. option:: --no-wheel

If set, don't attempt to install :ref:`pypug:wheel`
If set, do not attempt to install :ref:`pypug:wheel`


Additionally, ``get-pip.py`` supports using the :ref:`pip install options <pip
``get-pip.py`` allows :ref:`pip install options <pip
install Options>` and the :ref:`general options <General Options>`. Below are
some examples:

Expand Down Expand Up @@ -91,16 +89,12 @@ the `Python Packaging User Guide
Upgrading pip
-------------

On Linux or macOS:

::
On Linux or macOS::

pip install -U pip


On Windows [4]_:

::
On Windows [4]_::

python -m pip install -U pip

Expand Down
2 changes: 1 addition & 1 deletion news/setuptools.vendor
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgraded pkg_resources (via setuptools) to 35.0.2.
Upgraded pkg_resources (via setuptools) to 36.2.6.
48 changes: 41 additions & 7 deletions pip/_vendor/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import tempfile
import textwrap
import itertools
import inspect
from pkgutil import get_importer

try:
Expand Down Expand Up @@ -67,13 +68,15 @@
except ImportError:
importlib_machinery = None

from . import py31compat
from pip._vendor import appdirs
from pip._vendor import packaging
__import__('pip._vendor.packaging.version')
__import__('pip._vendor.packaging.specifiers')
__import__('pip._vendor.packaging.requirements')
__import__('pip._vendor.packaging.markers')


if (3, 0) < sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or later is required")

Expand Down Expand Up @@ -1550,7 +1553,7 @@ def _setup_prefix(self):
path = self.module_path
old = None
while path != old:
if _is_unpacked_egg(path):
if _is_egg_path(path):
self.egg_name = os.path.basename(path)
self.egg_info = os.path.join(path, 'EGG-INFO')
self.egg_root = path
Expand Down Expand Up @@ -1953,7 +1956,7 @@ def find_eggs_in_zip(importer, path_item, only=False):
# don't yield nested distros
return
for subitem in metadata.resource_listdir('/'):
if _is_unpacked_egg(subitem):
if _is_egg_path(subitem):
subpath = os.path.join(path_item, subitem)
for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath):
yield dist
Expand Down Expand Up @@ -2030,7 +2033,7 @@ def find_on_path(importer, path_item, only=False):
yield Distribution.from_location(
path_item, entry, metadata, precedence=DEVELOP_DIST
)
elif not only and _is_unpacked_egg(entry):
elif not only and _is_egg_path(entry):
dists = find_distributions(os.path.join(path_item, entry))
for dist in dists:
yield dist
Expand Down Expand Up @@ -2218,12 +2221,22 @@ def _normalize_cached(filename, _cache={}):
return result


def _is_egg_path(path):
"""
Determine if given path appears to be an egg.
"""
return (
path.lower().endswith('.egg')
)


def _is_unpacked_egg(path):
"""
Determine if given path appears to be an unpacked egg.
"""
return (
path.lower().endswith('.egg')
_is_egg_path(path) and
os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO'))
)


Expand Down Expand Up @@ -2937,6 +2950,7 @@ def parse(s):
return req


<<<<<<< HEAD
def _get_mro(cls):
"""Get an mro for a type or classic class"""
if not isinstance(cls, type):
Expand All @@ -2946,20 +2960,40 @@ class new_cls(cls, object):

return new_cls.__mro__[1:]
Copy link
Member

Choose a reason for hiding this comment

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

This bothers me, because we don't normally modify vendored files. But I guess it's needed to stop mypy complaining about the pkg_resources code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it won't hurt to make a PR to setuptools with just this change. 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, there's specifically a prohibition from modifying vendored files because of the inherent maintenance burden that creates. You would expect that change to get overwritten the next time the vendored library is updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jaraco I made pypa/setuptools#1092 a few days back. :)

Copy link
Member Author

@pradyunsg pradyunsg Jul 26, 2017

Choose a reason for hiding this comment

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

You would expect that change to get overwritten the next time the vendored library is updated.

Umm... It's been added to a patch that pip can apply on the vendored package. So, it would get updated but it's still fragile because the patch breaks if the line numbers change.

return cls.__mro__
||||||| merged common ancestors
def _get_mro(cls):
"""Get an mro for a type or classic class"""
if not isinstance(cls, type):

class cls(cls, object):
pass

return cls.__mro__[1:]
return cls.__mro__
=======
def _always_object(classes):
"""
Ensure object appears in the mro even
for old-style classes.
"""
if object not in classes:
return classes + (object,)
return classes
>>>>>>> master


def _find_adapter(registry, ob):
"""Return an adapter factory for `ob` from `registry`"""
for t in _get_mro(getattr(ob, '__class__', type(ob))):
types = _always_object(inspect.getmro(getattr(ob, '__class__', type(ob))))
for t in types:
if t in registry:
return registry[t]


def ensure_directory(path):
"""Ensure that the parent directory of `path` exists"""
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
os.makedirs(dirname)
py31compat.makedirs(dirname, exist_ok=True)


def _bypass_ensure_directory(path):
Expand Down
22 changes: 22 additions & 0 deletions pip/_vendor/pkg_resources/py31compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import errno
import sys


def _makedirs_31(path, exist_ok=False):
try:
os.makedirs(path)
except OSError as exc:
if not exist_ok or exc.errno != errno.EEXIST:
raise


# rely on compatibility behavior until mode considerations
# and exists_ok considerations are disentangled.
# See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663
needs_makedirs = (
sys.version_info < (3, 2, 5) or
(3, 3) <= sys.version_info < (3, 3, 6) or
(3, 4) <= sys.version_info < (3, 4, 1)
)
makedirs = _makedirs_31 if needs_makedirs else os.makedirs
6 changes: 3 additions & 3 deletions pip/_vendor/pytoml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .core import TomlError
from .parser import load, loads
from .writer import dump, dumps
from .core import TomlError
from .parser import load, loads
from .writer import dump, dumps
26 changes: 13 additions & 13 deletions pip/_vendor/pytoml/core.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class TomlError(RuntimeError):
def __init__(self, message, line, col, filename):
RuntimeError.__init__(self, message, line, col, filename)
self.message = message
self.line = line
self.col = col
self.filename = filename
def __str__(self):
return '{}({}, {}): {}'.format(self.filename, self.line, self.col, self.message)
def __repr__(self):
return 'TomlError({!r}, {!r}, {!r}, {!r})'.format(self.message, self.line, self.col, self.filename)
class TomlError(RuntimeError):
def __init__(self, message, line, col, filename):
RuntimeError.__init__(self, message, line, col, filename)
self.message = message
self.line = line
self.col = col
self.filename = filename

def __str__(self):
return '{}({}, {}): {}'.format(self.filename, self.line, self.col, self.message)

def __repr__(self):
return 'TomlError({!r}, {!r}, {!r}, {!r})'.format(self.message, self.line, self.col, self.filename)
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.