Skip to content

Commit c2a4ea4

Browse files
committed
Merge branch 'master' into refactor/reduce-action-at-distance
2 parents 255a518 + 83cb225 commit c2a4ea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2132
-7369
lines changed

Diff for: .gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Patches must have Unix-style line endings, even on Windows
2+
tasks/vendoring/patches/* eol=lf

Diff for: NEWS.rst

+16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@
77
88
.. towncrier release notes start
99
10+
11+
9.0.3 (2018-03-21)
12+
==================
13+
14+
- Fix an error where the vendored requests was not correctly containing itself
15+
to only the internal vendored prefix.
16+
- Restore compatibility with 2.6.
17+
18+
19+
9.0.2 (2018-03-16)
20+
==================
21+
22+
- Fallback to using SecureTransport on macOS when the linked OpenSSL is too old
23+
to support TLSv1.2.
24+
25+
1026
9.0.1 (2016-11-06)
1127
==================
1228

Diff for: docs/reference/pip.rst

+57-7
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ Build System Interface
7272
======================
7373

7474
Pip builds packages by invoking the build system. Presently, the only supported
75-
build system is ``setuptools``, but future developments to the Python packaging
76-
infrastructure are expected to include support for other build systems. As
77-
well as package building, the build system is also invoked to install packages
78-
direct from source.
75+
build system is ``setuptools``, but in the future, pip will support `PEP517`_
76+
which allows projects to specify an alternative build system in a
77+
``pyproject.toml`` file. As well as package building, the build system is also
78+
invoked to install packages direct from source. This is handled by invoking
79+
the build system to build a wheel, and then installing from that wheel. The
80+
built wheel is cached locally by pip to avoid repeated identical builds.
7981

80-
The interface to the build system is via the ``setup.py`` command line script -
81-
all build actions are defined in terms of the specific ``setup.py`` command
82-
line that will be run to invoke the required action.
82+
The current interface to the build system is via the ``setup.py`` command line
83+
script - all build actions are defined in terms of the specific ``setup.py``
84+
command line that will be run to invoke the required action.
8385

8486
Setuptools Injection
8587
~~~~~~~~~~~~~~~~~~~~
@@ -111,6 +113,54 @@ unexpected byte sequences to Python-style hexadecimal escape sequences
111113
(``"\x80\xff"``, etc). However, it is still possible for output to be displayed
112114
using an incorrect encoding (mojibake).
113115

116+
PEP 518 Support
117+
~~~~~~~~~~~~~~~
118+
119+
Pip supports projects declaring dependencies that are required at install time
120+
using a ``pyproject.toml`` file, in the form described in `PEP518`_. When
121+
building a project, pip will install the required dependencies locally, and
122+
make them available to the build process.
123+
124+
As noted in the PEP, the minimum requirements for pip to be able to build a
125+
project are::
126+
127+
[build-system]
128+
# Minimum requirements for the build system to execute.
129+
requires = ["setuptools", "wheel"]
130+
131+
``setuptools`` and ``wheel`` **must** be included in any ``pyproject.toml``
132+
provided by a project - pip will assume these as a default, but will not add
133+
them to an explicitly supplied list in a project supplied ``pyproject.toml``
134+
file. Once `PEP517`_ support is added, this restriction will be lifted and
135+
alternative build tools will be allowed.
136+
137+
When making build requirements available, pip does so in an *isolated
138+
environment*. That is, pip does not install those requirements into the user's
139+
``site-packages``, but rather installs them in a temporary directory which it
140+
adds to the user's ``sys.path`` for the duration of the build. This ensures
141+
that build requirements are handled independently of the user's runtime
142+
environment. For example, a project that needs a recent version of setuptools
143+
to build can still be installed, even if the user has an older version
144+
installed (and without silently replacing that version).
145+
146+
In certain cases, projects (or redistributors) may have workflows that
147+
explicitly manage the build environment. For such workflows, build isolation
148+
can be problematic. If this is the case, pip provides a
149+
``--no-build-isolation`` flag to disable build isolation. Users supplying this
150+
flag are responsible for ensuring the build environment is managed
151+
appropriately.
152+
153+
The current implementation of `PEP518`_ in pip requires that any dependencies
154+
specified in ``pyproject.toml`` are available as wheels. This is a technical
155+
limitation of the implementation - dependencies only available as source would
156+
require a build step of their own, which would recursively invoke the `PEP518`_
157+
dependency installation process. The potentially unbounded recursion involved
158+
was not considered acceptable, and so installation of build dependencies from
159+
source has been disabled until a safe resolution of this issue has been found.
160+
161+
.. _PEP517: http://www.python.org/dev/peps/pep-0517/
162+
.. _PEP518: http://www.python.org/dev/peps/pep-0518/
163+
114164
Future Developments
115165
~~~~~~~~~~~~~~~~~~~
116166

Diff for: news/36f6f515-fa9e-4d45-84fd-740a5c09752e.trivial

Whitespace-only changes.

Diff for: news/3763.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Keep install options in requirements.txt from leaking.

Diff for: news/4454.bugfix

-2
This file was deleted.

Diff for: news/4954.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add auto completion of short options.

Diff for: news/4966.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Terminal size is now correctly inferred when using Python 3 on Windows.

Diff for: news/5085.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a ``--no-user`` option and use it when installing build dependencies.

Diff for: src/pip/_internal/__init__.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ def autocomplete():
105105
sys.exit(1)
106106

107107
subcommand = commands_dict[subcommand_name]()
108-
options += [(opt.get_opt_string(), opt.nargs)
109-
for opt in subcommand.parser.option_list_all
110-
if opt.help != optparse.SUPPRESS_HELP]
108+
109+
for opt in subcommand.parser.option_list_all:
110+
if opt.help != optparse.SUPPRESS_HELP:
111+
for opt_str in opt._long_opts + opt._short_opts:
112+
options.append((opt_str, opt.nargs))
111113

112114
# filter out previously specified options from available options
113115
prev_opts = [x.split('=')[0] for x in cwords[1:cword - 1]]
@@ -117,7 +119,7 @@ def autocomplete():
117119
for option in options:
118120
opt_label = option[0]
119121
# append '=' to options which require args
120-
if option[1]:
122+
if option[1] and option[0][:2] == "--":
121123
opt_label += '='
122124
print(opt_label)
123125
else:
@@ -127,8 +129,9 @@ def autocomplete():
127129
opts.append(parser.option_list)
128130
opts = (o for it in opts for o in it)
129131

130-
subcommands += [i.get_opt_string() for i in opts
131-
if i.help != optparse.SUPPRESS_HELP]
132+
for opt in opts:
133+
if opt.help != optparse.SUPPRESS_HELP:
134+
subcommands += opt._long_opts + opt._short_opts
132135

133136
print(' '.join([x for x in subcommands if x.startswith(current)]))
134137
sys.exit(1)

Diff for: src/pip/_internal/baseparser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from pip._vendor.six import string_types
1111

12+
from pip._internal.compat import get_terminal_size
1213
from pip._internal.configuration import Configuration, ConfigurationError
13-
from pip._internal.utils.misc import get_terminal_size
1414

1515
logger = logging.getLogger(__name__)
1616

Diff for: src/pip/_internal/build_env.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __enter__(self):
2424

2525
self.save_path = os.environ.get('PATH', None)
2626
self.save_pythonpath = os.environ.get('PYTHONPATH', None)
27+
self.save_nousersite = os.environ.get('PYTHONNOUSERSITE', None)
2728

2829
install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
2930
install_dirs = get_paths(install_scheme, vars={
@@ -48,20 +49,23 @@ def __enter__(self):
4849
else:
4950
os.environ['PYTHONPATH'] = lib_dirs
5051

52+
os.environ['PYTHONNOUSERSITE'] = '1'
53+
5154
return self.path
5255

5356
def __exit__(self, exc_type, exc_val, exc_tb):
5457
if not self._no_clean:
5558
self._temp_dir.cleanup()
56-
if self.save_path is None:
57-
os.environ.pop('PATH', None)
58-
else:
59-
os.environ['PATH'] = self.save_path
6059

61-
if self.save_pythonpath is None:
62-
os.environ.pop('PYTHONPATH', None)
63-
else:
64-
os.environ['PYTHONPATH'] = self.save_pythonpath
60+
def restore_var(varname, old_value):
61+
if old_value is None:
62+
os.environ.pop(varname, None)
63+
else:
64+
os.environ[varname] = old_value
65+
66+
restore_var('PATH', self.save_path)
67+
restore_var('PYTHONPATH', self.save_pythonpath)
68+
restore_var('PYTHONNOUSERSITE', self.save_nousersite)
6569

6670
def cleanup(self):
6771
self._temp_dir.cleanup()

Diff for: src/pip/_internal/cmdoptions.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def only_binary():
429429
dest='ignore_dependencies',
430430
action='store_true',
431431
default=False,
432-
help="Don't install package dependencies)."
432+
help="Don't install package dependencies.",
433433
) # type: Any
434434

435435
build_dir = partial(
@@ -451,6 +451,17 @@ def only_binary():
451451
help='Ignore the Requires-Python information.'
452452
) # type: Any
453453

454+
no_build_isolation = partial(
455+
Option,
456+
'--no-build-isolation',
457+
dest='build_isolation',
458+
action='store_false',
459+
default=True,
460+
help='Disable isolation when building a modern source distribution. '
461+
'Build dependencies specified by PEP 518 must be already installed '
462+
'if this option is used.'
463+
) # type: Any
464+
454465
install_options = partial(
455466
Option,
456467
'--install-option',

Diff for: src/pip/_internal/commands/configuration.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,7 @@
1313

1414

1515
class ConfigurationCommand(Command):
16-
"""Manage local and global configuration."""
17-
name = 'config'
18-
usage = """
19-
%prog [<file-option>] list
20-
%prog [<file-option>] [--editor <editor-path>] edit
21-
22-
%prog [<file-option>] get name
23-
%prog [<file-option>] set name value
24-
%prog [<file-option>] unset name
25-
"""
26-
27-
summary = """
28-
Manage local and global configuration.
16+
"""Manage local and global configuration.
2917
3018
Subcommands:
3119
@@ -41,6 +29,18 @@ class ConfigurationCommand(Command):
4129
default.
4230
"""
4331

32+
name = 'config'
33+
usage = """
34+
%prog [<file-option>] list
35+
%prog [<file-option>] [--editor <editor-path>] edit
36+
37+
%prog [<file-option>] get name
38+
%prog [<file-option>] set name value
39+
%prog [<file-option>] unset name
40+
"""
41+
42+
summary = "Manage local and global configuration."
43+
4444
def __init__(self, *args, **kwargs):
4545
super(ConfigurationCommand, self).__init__(*args, **kwargs)
4646

Diff for: src/pip/_internal/commands/download.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(self, *args, **kw):
5757
cmd_opts.add_option(cmdoptions.no_clean())
5858
cmd_opts.add_option(cmdoptions.require_hashes())
5959
cmd_opts.add_option(cmdoptions.progress_bar())
60+
cmd_opts.add_option(cmdoptions.no_build_isolation())
6061

6162
cmd_opts.add_option(
6263
'-d', '--dest', '--destination-dir', '--destination-directory',
@@ -201,6 +202,7 @@ def run(self, options, args):
201202
download_dir=options.download_dir,
202203
wheel_download_dir=None,
203204
progress_bar=options.progress_bar,
205+
build_isolation=options.build_isolation,
204206
)
205207

206208
resolver = Resolver(

Diff for: src/pip/_internal/commands/install.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import operator
66
import os
77
import shutil
8+
from optparse import SUPPRESS_HELP
89

910
from pip._internal import cmdoptions
1011
from pip._internal.basecommand import RequirementCommand
@@ -14,7 +15,7 @@
1415
)
1516
from pip._internal.locations import distutils_scheme, virtualenv_no_global
1617
from pip._internal.operations.prepare import RequirementPreparer
17-
from pip._internal.req import RequirementSet
18+
from pip._internal.req import RequirementSet, install_given_reqs
1819
from pip._internal.resolve import Resolver
1920
from pip._internal.status_codes import ERROR
2021
from pip._internal.utils.filesystem import check_path_owner
@@ -83,6 +84,11 @@ def __init__(self, *args, **kw):
8384
"platform. Typically ~/.local/, or %APPDATA%\\Python on "
8485
"Windows. (See the Python documentation for site.USER_BASE "
8586
"for full details.)")
87+
cmd_opts.add_option(
88+
'--no-user',
89+
dest='use_user_site',
90+
action='store_false',
91+
help=SUPPRESS_HELP)
8692
cmd_opts.add_option(
8793
'--root',
8894
dest='root_path',
@@ -139,6 +145,7 @@ def __init__(self, *args, **kw):
139145
help='Ignore the installed packages (reinstalling instead).')
140146

141147
cmd_opts.add_option(cmdoptions.ignore_requires_python())
148+
cmd_opts.add_option(cmdoptions.no_build_isolation())
142149

143150
cmd_opts.add_option(cmdoptions.install_options())
144151
cmd_opts.add_option(cmdoptions.global_options())
@@ -257,6 +264,7 @@ def run(self, options, args):
257264
download_dir=None,
258265
wheel_download_dir=None,
259266
progress_bar=options.progress_bar,
267+
build_isolation=options.build_isolation,
260268
)
261269

262270
resolver = Resolver(
@@ -289,7 +297,11 @@ def run(self, options, args):
289297
session=session, autobuilding=True
290298
)
291299

292-
installed = requirement_set.install(
300+
to_install = resolver.get_installation_order(
301+
requirement_set
302+
)
303+
installed = install_given_reqs(
304+
to_install,
293305
install_options,
294306
global_options,
295307
root=options.root_path,

Diff for: src/pip/_internal/commands/search.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from pip._vendor.six.moves import xmlrpc_client # type: ignore
1313

1414
from pip._internal.basecommand import SUCCESS, Command
15+
from pip._internal.compat import get_terminal_size
1516
from pip._internal.download import PipXmlrpcTransport
1617
from pip._internal.exceptions import CommandError
1718
from pip._internal.models import PyPI
1819
from pip._internal.status_codes import NO_MATCHES_FOUND
1920
from pip._internal.utils.logging import indent_log
20-
from pip._internal.utils.misc import get_terminal_size
2121

2222
logger = logging.getLogger(__name__)
2323

Diff for: src/pip/_internal/commands/show.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
import os
5-
from email.parser import FeedParser
5+
from email.parser import FeedParser # type: ignore
66

77
from pip._vendor import pkg_resources
88
from pip._vendor.packaging.utils import canonicalize_name

Diff for: src/pip/_internal/commands/wheel.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def __init__(self, *args, **kw):
6363
dest='build_options',
6464
metavar='options',
6565
action='append',
66-
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.")
66+
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
67+
)
68+
cmd_opts.add_option(cmdoptions.no_build_isolation())
6769
cmd_opts.add_option(cmdoptions.constraints())
6870
cmd_opts.add_option(cmdoptions.editable())
6971
cmd_opts.add_option(cmdoptions.requirements())
@@ -158,6 +160,7 @@ def run(self, options, args):
158160
download_dir=None,
159161
wheel_download_dir=options.wheel_dir,
160162
progress_bar=options.progress_bar,
163+
build_isolation=options.build_isolation,
161164
)
162165

163166
resolver = Resolver(

0 commit comments

Comments
 (0)