Skip to content

Commit 6951267

Browse files
committed
Merge branch 'master' into release_19.3.1
and drop master news file already included in 19.3.1
2 parents 00e3f9f + 554207e commit 6951267

21 files changed

+116
-42
lines changed

docs/html/development/getting-started.rst

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ To run tests locally, run:
4040
4141
$ tox -e py36
4242
43+
Generally, it can take a long time to run pip's test suite. To run tests in parallel,
44+
which is faster, run:
45+
46+
.. code-block:: console
47+
48+
$ tox -e py36 -- -n auto
49+
4350
The example above runs tests against Python 3.6. You can also use other
4451
versions like ``py27`` and ``pypy3``.
4552

docs/html/installing.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ Just make sure to :ref:`upgrade pip <Upgrading pip>`.
1818
Installing with get-pip.py
1919
--------------------------
2020

21-
To install pip, securely download `get-pip.py
22-
<https://bootstrap.pypa.io/get-pip.py>`_. [1]_::
21+
To install pip, securely [1]_ download ``get-pip.py`` by following
22+
this link: `get-pip.py
23+
<https://bootstrap.pypa.io/get-pip.py>`_. Alternatively, use ``curl``::
2324

2425
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2526

26-
Then run the following::
27+
Then run the following command in the folder where you
28+
have downloaded ``get-pip.py``::
2729

2830
python get-pip.py
2931

news/7146.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Display CA information in ``pip debug``.

news/7191.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change method from shutil.remove to shutil.rmtree in noxfile.py.

news/7193.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip running tests which require subversion, when svn isn't installed

news/7199.trivial

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
adding line in trivial file to avoid linter issues.

news/7222.doc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add more clear installation instructions

news/7225.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Show only the filename (instead of full URL), when downloading from PyPI.

noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def should_update_common_wheels():
7676

7777
# Clear the stale cache.
7878
if need_to_repopulate:
79-
shutil.remove(LOCATIONS["common-wheels"], ignore_errors=True)
79+
shutil.rmtree(LOCATIONS["common-wheels"], ignore_errors=True)
8080

8181
return need_to_repopulate
8282

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def find_version(*file_paths):
7676
entry_points={
7777
"console_scripts": [
7878
"pip=pip._internal.main:main",
79-
"pip%s=pip._internal.main:main" % sys.version_info[:1],
80-
"pip%s.%s=pip._internal.main:main" % sys.version_info[:2],
79+
"pip{}=pip._internal.main:main".format(sys.version_info[0]),
80+
"pip{}.{}=pip._internal.main:main".format(*sys.version_info[:2]),
8181
],
8282
},
8383

src/pip/_internal/commands/debug.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
import locale
77
import logging
8+
import os
89
import sys
910

11+
from pip._vendor.certifi import where
12+
1013
from pip._internal.cli import cmdoptions
1114
from pip._internal.cli.base_command import Command
1215
from pip._internal.cli.cmdoptions import make_target_python
@@ -17,14 +20,14 @@
1720
from pip._internal.wheel import format_tag
1821

1922
if MYPY_CHECK_RUNNING:
20-
from typing import Any, List
23+
from typing import Any, List, Optional
2124
from optparse import Values
2225

2326
logger = logging.getLogger(__name__)
2427

2528

2629
def show_value(name, value):
27-
# type: (str, str) -> None
30+
# type: (str, Optional[str]) -> None
2831
logger.info('{}: {}'.format(name, value))
2932

3033

@@ -75,6 +78,25 @@ def show_tags(options):
7578
logger.info(msg)
7679

7780

81+
def ca_bundle_info(config):
82+
levels = set()
83+
for key, value in config.items():
84+
levels.add(key.split('.')[0])
85+
86+
if not levels:
87+
return "Not specified"
88+
89+
levels_that_override_global = ['install', 'wheel', 'download']
90+
global_overriding_level = [
91+
level for level in levels if level in levels_that_override_global
92+
]
93+
if not global_overriding_level:
94+
return 'global'
95+
96+
levels.remove('global')
97+
return ", ".join(levels)
98+
99+
78100
class DebugCommand(Command):
79101
"""
80102
Display debug information.
@@ -90,6 +112,7 @@ def __init__(self, *args, **kw):
90112
cmd_opts = self.cmd_opts
91113
cmdoptions.add_target_python_options(cmd_opts)
92114
self.parser.insert_option_group(0, cmd_opts)
115+
self.parser.config.load()
93116

94117
def run(self, options, args):
95118
# type: (Values, List[Any]) -> int
@@ -110,6 +133,11 @@ def run(self, options, args):
110133
show_value('sys.platform', sys.platform)
111134
show_sys_implementation()
112135

136+
show_value("'cert' config value", ca_bundle_info(self.parser.config))
137+
show_value("REQUESTS_CA_BUNDLE", os.environ.get('REQUESTS_CA_BUNDLE'))
138+
show_value("CURL_CA_BUNDLE", os.environ.get('CURL_CA_BUNDLE'))
139+
show_value("pip._vendor.certifi.where()", where())
140+
113141
show_tags(options)
114142

115143
return SUCCESS

src/pip/_internal/download.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ def _download_url(
180180
else:
181181
show_progress = False
182182

183-
show_url = link.show_url
184-
185183
def resp_read(chunk_size):
186184
try:
187185
# Special case for urllib3.
@@ -226,8 +224,8 @@ def written_chunks(chunks):
226224

227225
progress_indicator = _progress_indicator
228226

229-
if link.netloc == PyPI.netloc:
230-
url = show_url
227+
if link.netloc == PyPI.file_storage_domain:
228+
url = link.show_url
231229
else:
232230
url = link.url_without_fragment
233231

src/pip/_internal/req/req_install.py

+27-20
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@
7373
logger = logging.getLogger(__name__)
7474

7575

76+
def _get_dist(metadata_directory):
77+
# type: (str) -> Distribution
78+
"""Return a pkg_resources.Distribution for the provided
79+
metadata directory.
80+
"""
81+
dist_dir = metadata_directory.rstrip(os.sep)
82+
83+
# Determine the correct Distribution object type.
84+
if dist_dir.endswith(".egg-info"):
85+
dist_cls = pkg_resources.Distribution
86+
else:
87+
assert dist_dir.endswith(".dist-info")
88+
dist_cls = pkg_resources.DistInfoDistribution
89+
90+
# Build a PathMetadata object, from path to metadata. :wink:
91+
base_dir, dist_dir_name = os.path.split(dist_dir)
92+
dist_name = os.path.splitext(dist_dir_name)[0]
93+
metadata = pkg_resources.PathMetadata(base_dir, dist_dir)
94+
95+
return dist_cls(
96+
base_dir,
97+
project_name=dist_name,
98+
metadata=metadata,
99+
)
100+
101+
76102
class InstallRequirement(object):
77103
"""
78104
Represents something that may be installed later on, may have information
@@ -619,26 +645,7 @@ def metadata(self):
619645

620646
def get_dist(self):
621647
# type: () -> Distribution
622-
"""Return a pkg_resources.Distribution for this requirement"""
623-
dist_dir = self.metadata_directory.rstrip(os.sep)
624-
625-
# Determine the correct Distribution object type.
626-
if dist_dir.endswith(".egg-info"):
627-
dist_cls = pkg_resources.Distribution
628-
else:
629-
assert dist_dir.endswith(".dist-info")
630-
dist_cls = pkg_resources.DistInfoDistribution
631-
632-
# Build a PathMetadata object, from path to metadata. :wink:
633-
base_dir, dist_dir_name = os.path.split(dist_dir)
634-
dist_name = os.path.splitext(dist_dir_name)[0]
635-
metadata = pkg_resources.PathMetadata(base_dir, dist_dir)
636-
637-
return dist_cls(
638-
base_dir,
639-
project_name=dist_name,
640-
metadata=metadata,
641-
)
648+
return _get_dist(self.metadata_directory)
642649

643650
def assert_source_matches_version(self):
644651
# type: () -> None

tests/functional/test_debug.py

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
'locale.getpreferredencoding: ',
1111
'sys.platform: ',
1212
'sys.implementation:',
13+
'\'cert\' config value: ',
14+
'REQUESTS_CA_BUNDLE: ',
15+
'CURL_CA_BUNDLE: ',
16+
'pip._vendor.certifi.where(): ',
17+
1318
])
1419
def test_debug(script, expected_text):
1520
"""

tests/functional/test_freeze.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
_git_commit,
1313
need_bzr,
1414
need_mercurial,
15+
need_svn,
1516
path_to_url,
1617
)
1718

@@ -169,7 +170,7 @@ def test_freeze_editable_git_with_no_remote(script, tmpdir, deprecated_python):
169170
_check_output(result.stdout, expected)
170171

171172

172-
@pytest.mark.svn
173+
@need_svn
173174
def test_freeze_svn(script, tmpdir):
174175
"""Test freezing a svn checkout"""
175176

tests/functional/test_install.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
create_test_package_with_setup,
2222
need_bzr,
2323
need_mercurial,
24+
need_svn,
2425
path_to_url,
2526
pyversion,
2627
pyversion_tuple,
@@ -225,7 +226,7 @@ def test_basic_install_from_pypi(script):
225226
"""
226227
Test installing a package from PyPI.
227228
"""
228-
result = script.pip('install', '-vvv', 'INITools==0.2')
229+
result = script.pip('install', 'INITools==0.2')
229230
egg_info_folder = (
230231
script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
231232
)
@@ -237,6 +238,13 @@ def test_basic_install_from_pypi(script):
237238
assert "Looking in indexes: " not in result.stdout
238239
assert "Looking in links: " not in result.stdout
239240

241+
# Ensure that we don't print the full URL.
242+
# The URL should be trimmed to only the last part of the path in it,
243+
# when installing from PyPI. The assertion here only checks for
244+
# `https://` since that's likely to show up if we're not trimming in
245+
# the correct circumstances.
246+
assert "https://" not in result.stdout
247+
240248

241249
def test_basic_editable_install(script):
242250
"""
@@ -251,7 +259,7 @@ def test_basic_editable_install(script):
251259
assert not result.files_updated
252260

253261

254-
@pytest.mark.svn
262+
@need_svn
255263
def test_basic_install_editable_from_svn(script):
256264
"""
257265
Test checking out from svn.

tests/functional/test_install_reqs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from tests.lib import (
77
_create_test_package_with_subdirectory,
8+
need_svn,
89
path_to_url,
910
pyversion,
1011
requirements_file,
@@ -100,7 +101,7 @@ def test_relative_requirements_file(script, data):
100101

101102

102103
@pytest.mark.network
103-
@pytest.mark.svn
104+
@need_svn
104105
def test_multiple_requirements_files(script, tmpdir):
105106
"""
106107
Test installing from multiple nested requirements files.

tests/functional/test_install_user.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from tests.lib import pyversion
9+
from tests.lib import need_svn, pyversion
1010
from tests.lib.local_repos import local_checkout
1111

1212

@@ -41,7 +41,7 @@ def test_reset_env_system_site_packages_usersite(self, script):
4141
assert 'INITools' == project_name, project_name
4242

4343
@pytest.mark.network
44-
@pytest.mark.svn
44+
@need_svn
4545
def test_install_subversion_usersite_editable_with_distribute(
4646
self, script, tmpdir):
4747
"""

tests/functional/test_uninstall.py

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

1414
from pip._internal.req.constructors import install_req_from_line
1515
from pip._internal.utils.misc import rmtree
16-
from tests.lib import assert_all_changes, create_test_package_with_setup
16+
from tests.lib import (
17+
assert_all_changes,
18+
create_test_package_with_setup,
19+
need_svn,
20+
)
1721
from tests.lib.local_repos import local_checkout, local_repo
1822

1923

@@ -289,6 +293,7 @@ def test_uninstall_easy_installed_console_scripts(script):
289293

290294

291295
@pytest.mark.network
296+
@need_svn
292297
def test_uninstall_editable_from_svn(script, tmpdir):
293298
"""
294299
Test uninstalling an editable installation from svn.
@@ -352,7 +357,7 @@ def _test_uninstall_editable_with_source_outside_venv(
352357

353358

354359
@pytest.mark.network
355-
@pytest.mark.svn
360+
@need_svn
356361
def test_uninstall_from_reqs_file(script, tmpdir):
357362
"""
358363
Test uninstall from a requirements file.

tests/lib/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,12 @@ def need_bzr(fn):
10371037
)(fn))
10381038

10391039

1040+
def need_svn(fn):
1041+
return pytest.mark.svn(need_executable(
1042+
'Subversion', ('svn', '--version')
1043+
)(fn))
1044+
1045+
10401046
def need_mercurial(fn):
10411047
return pytest.mark.mercurial(need_executable(
10421048
'Mercurial', ('hg', 'version')

tests/unit/test_vcs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pip._internal.vcs.mercurial import Mercurial
1414
from pip._internal.vcs.subversion import Subversion
1515
from pip._internal.vcs.versioncontrol import RevOptions, VersionControl
16-
from tests.lib import is_svn_installed, pyversion
16+
from tests.lib import is_svn_installed, need_svn, pyversion
1717

1818
if pyversion >= '3':
1919
VERBOSE_FALSE = False
@@ -411,7 +411,7 @@ def test_subversion__init_use_interactive(
411411
assert svn.use_interactive == expected
412412

413413

414-
@pytest.mark.svn
414+
@need_svn
415415
def test_subversion__call_vcs_version():
416416
"""
417417
Test Subversion.call_vcs_version() against local ``svn``.

0 commit comments

Comments
 (0)