Skip to content

Commit b911339

Browse files
committed
Merge remote-tracking branch 'pypa/develop' into refactor_req_file
Conflicts: pip/req/req_file.py
2 parents fdd10ad + 3376460 commit b911339

22 files changed

+180
-126
lines changed

docs/reference/pip_install.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ the project path. This is one advantage over just using ``setup.py develop``,
453453
which creates the "egg-info" directly relative the current working directory.
454454

455455

456+
.. _`controlling-setup-requires`:
456457

457458
Controlling setup_requires
458459
++++++++++++++++++++++++++

docs/user_guide.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ From within a real python, where ``SomePackage`` *is* installed globally, and is
535535
Ensuring Repeatability
536536
**********************
537537

538-
Three things are required to fully guarantee a repeatable installation using requirements files.
538+
Four things are required to fully guarantee a repeatable installation using requirements files.
539539

540540
1. The requirements file was generated by ``pip freeze`` or you're sure it only
541541
contains requirements that specify a specific version.
@@ -544,15 +544,14 @@ Three things are required to fully guarantee a repeatable installation using req
544544
This guarantees that only what is explicitly listed in the requirements file is
545545
installed.
546546

547-
3. The installation is performed against an index or find-links location that is
547+
3. None of the packages to be installed utilize the setup_requires keyword. See
548+
:ref:`Controlling setup_requires<controlling-setup-requires>`.
549+
550+
4. The installation is performed against an index or find-links location that is
548551
guaranteed to *not* allow archives to be changed and updated without a
549-
version increase. Unfortunately, this is *not* true on PyPI. It is possible
550-
for the same pypi distribution to have a different hash over time. Project
551-
authors are allowed to delete a distribution, and then upload a new one with
552-
the same name and version, but a different hash. See `Issue #1175
553-
<https://github.com/pypa/pip/issues/1175>`_ for plans to add hash
554-
confirmation to pip, or a new "lock file" notion, but for now, know that the `peep
555-
project <https://pypi.python.org/pypi/peep>`_ offers this feature on top of pip
552+
version increase. While this is safe on PyPI, it may not be safe for other
553+
indices. If you are working with an unsafe index, consider the `peep project
554+
<https://pypi.python.org/pypi/peep>`_ which offers this feature on top of pip
556555
using requirements file comments.
557556

558557

@@ -576,4 +575,4 @@ Once you have a bundle, you can then install it using::
576575

577576
$ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
578577
$ (cd $tempdir; tar -xvf /path/to/bundled.tar.bz2)
579-
$ pip install --force-reinstall --ignore-installed --upgrade --no-index --use-wheel --no-deps $tempdir/*
578+
$ pip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps $tempdir/*

pip/basecommand.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def main(self, args):
109109
options, args = self.parse_args(args)
110110

111111
if options.quiet:
112-
level = "WARNING"
112+
if options.quiet == 1:
113+
level = "WARNING"
114+
if options.quiet == 2:
115+
level = "ERROR"
116+
else:
117+
level = "CRITICAL"
113118
elif options.verbose:
114119
level = "DEBUG"
115120
else:
@@ -281,15 +286,15 @@ class RequirementCommand(Command):
281286

282287
@staticmethod
283288
def populate_requirement_set(requirement_set, args, options, finder,
284-
session, name):
289+
session, name, wheel_cache):
285290
"""
286291
Marshal cmd line args into a requirement set.
287292
"""
288293
for name in args:
289294
requirement_set.add_requirement(
290295
InstallRequirement.from_line(
291296
name, None, isolated=options.isolated_mode,
292-
cache_root=options.cache_dir
297+
wheel_cache=wheel_cache
293298
)
294299
)
295300

@@ -299,14 +304,15 @@ def populate_requirement_set(requirement_set, args, options, finder,
299304
name,
300305
default_vcs=options.default_vcs,
301306
isolated=options.isolated_mode,
302-
cache_root=options.cache_dir
307+
wheel_cache=wheel_cache
303308
)
304309
)
305310

306311
for filename in options.requirements:
307312
for req in parse_requirements(
308313
filename,
309-
finder=finder, options=options, session=session):
314+
finder=finder, options=options, session=session,
315+
wheel_cache=wheel_cache):
310316
requirement_set.add_requirement(req)
311317

312318
if not requirement_set.has_requirements:

pip/commands/freeze.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pip.basecommand import Command
66
from pip.operations.freeze import freeze
7+
from pip.wheel import WheelCache
78

89

910
class FreezeCommand(Command):
@@ -54,14 +55,15 @@ def __init__(self, *args, **kw):
5455
self.parser.insert_option_group(0, self.cmd_opts)
5556

5657
def run(self, options, args):
58+
wheel_cache = WheelCache(options.cache_dir)
5759
freeze_kwargs = dict(
5860
requirement=options.requirement,
5961
find_links=options.find_links,
6062
local_only=options.local,
6163
user_only=options.user,
6264
skip_regex=options.skip_requirements_regex,
6365
isolated=options.isolated_mode,
64-
cache_root=options.cache_dir)
66+
wheel_cache=wheel_cache)
6567

6668
for line in freeze(**freeze_kwargs):
6769
sys.stdout.write(line + '\n')

pip/commands/install.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pip.utils import ensure_dir
2323
from pip.utils.build import BuildDirectory
2424
from pip.utils.deprecation import RemovedInPip8Warning
25-
from pip.wheel import WheelBuilder
25+
from pip.wheel import WheelCache, WheelBuilder
2626

2727

2828
logger = logging.getLogger(__name__)
@@ -239,11 +239,11 @@ def run(self, options, args):
239239

240240
finder = self._build_package_finder(options, index_urls, session)
241241
build_delete = (not (options.no_clean or options.build_dir))
242+
wheel_cache = WheelCache(options.cache_dir)
242243
with BuildDirectory(options.build_dir,
243244
delete=build_delete) as build_dir:
244245
requirement_set = RequirementSet(
245246
build_dir=build_dir,
246-
cache_root=options.cache_dir,
247247
src_dir=options.src_dir,
248248
download_dir=options.download_dir,
249249
upgrade=options.upgrade,
@@ -256,10 +256,12 @@ def run(self, options, args):
256256
session=session,
257257
pycompile=options.compile,
258258
isolated=options.isolated_mode,
259+
wheel_cache=wheel_cache,
259260
)
260261

261262
self.populate_requirement_set(
262263
requirement_set, args, options, finder, session, self.name,
264+
wheel_cache
263265
)
264266

265267
if not requirement_set.has_requirements:

pip/commands/list.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import logging
44

5+
from pip._vendor import pkg_resources
6+
57
from pip.basecommand import Command
68
from pip.exceptions import DistributionNotFound
7-
from pip.index import PackageFinder
9+
from pip.index import PackageFinder, Search
810
from pip.req import InstallRequirement
911
from pip.utils import get_installed_distributions, dist_is_editable
12+
from pip.wheel import WheelCache
1013
from pip.cmdoptions import make_option_group, index_group
1114

1215

@@ -128,10 +131,11 @@ def find_packages_latest_versions(self, options):
128131
user_only=options.user,
129132
include_editables=False,
130133
)
134+
wheel_cache = WheelCache(options.cache_dir)
131135
for dist in installed_packages:
132136
req = InstallRequirement.from_line(
133137
dist.key, None, isolated=options.isolated_mode,
134-
cache_root=options.cache_dir,
138+
wheel_cache=wheel_cache
135139
)
136140
typ = 'unknown'
137141
try:
@@ -144,9 +148,12 @@ def find_packages_latest_versions(self, options):
144148
except DistributionNotFound:
145149
continue
146150
else:
151+
search = Search(
152+
req.name,
153+
pkg_resources.safe_name(req.name).lower(),
154+
["source", "binary"])
147155
remote_version = finder._link_package_versions(
148-
link, req.name
149-
).version
156+
link, search).version
150157
if link.is_wheel:
151158
typ = 'wheel'
152159
else:

pip/commands/uninstall.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import absolute_import
22

3+
from pip.wheel import WheelCache
34
from pip.req import InstallRequirement, RequirementSet, parse_requirements
45
from pip.basecommand import Command
56
from pip.exceptions import InstallationError
@@ -42,28 +43,28 @@ def __init__(self, *args, **kw):
4243

4344
def run(self, options, args):
4445
with self._build_session(options) as session:
45-
46+
wheel_cache = WheelCache(options.cache_dir)
4647
requirement_set = RequirementSet(
4748
build_dir=None,
48-
cache_root=options.cache_dir,
4949
src_dir=None,
5050
download_dir=None,
5151
isolated=options.isolated_mode,
5252
session=session,
53+
wheel_cache=wheel_cache,
5354
)
5455
for name in args:
5556
requirement_set.add_requirement(
5657
InstallRequirement.from_line(
5758
name, isolated=options.isolated_mode,
58-
cache_root=options.cache_dir,
59+
wheel_cache=wheel_cache
5960
)
6061
)
6162
for filename in options.requirements:
6263
for req in parse_requirements(
6364
filename,
6465
options=options,
6566
session=session,
66-
cache_root=options.cache_dir):
67+
wheel_cache=wheel_cache):
6768
requirement_set.add_requirement(req)
6869
if not requirement_set.has_requirements:
6970
raise InstallationError(

pip/commands/wheel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pip.utils import import_or_raise, normalize_path
1313
from pip.utils.build import BuildDirectory
1414
from pip.utils.deprecation import RemovedInPip8Warning
15-
from pip.wheel import WheelBuilder
15+
from pip.wheel import WheelCache, WheelBuilder
1616
from pip import cmdoptions
1717

1818
DEFAULT_WHEEL_DIR = os.path.join(normalize_path(os.curdir), 'wheelhouse')
@@ -155,22 +155,24 @@ def run(self, options, args):
155155
)
156156

157157
build_delete = (not (options.no_clean or options.build_dir))
158+
wheel_cache = WheelCache(options.cache_dir)
158159
with BuildDirectory(options.build_dir,
159160
delete=build_delete) as build_dir:
160161
requirement_set = RequirementSet(
161162
build_dir=build_dir,
162-
cache_root=options.cache_dir,
163163
src_dir=options.src_dir,
164164
download_dir=None,
165165
ignore_dependencies=options.ignore_dependencies,
166166
ignore_installed=True,
167167
isolated=options.isolated_mode,
168168
session=session,
169+
wheel_cache=wheel_cache,
169170
wheel_download_dir=options.wheel_dir
170171
)
171172

172173
self.populate_requirement_set(
173174
requirement_set, args, options, finder, session, self.name,
175+
wheel_cache
174176
)
175177

176178
if not requirement_set.has_requirements:

0 commit comments

Comments
 (0)