Repository: pypa/pip

Issue:
Switch default URLs to Warehouse
We'll want to switch the relevant URLs to defaulting to the new Warehouse URLs!


Discussion:

Resolving patch:
diff --git a/src/pip/_internal/index.py b/src/pip/_internal/index.py
--- a/src/pip/_internal/index.py
+++ b/src/pip/_internal/index.py
@@ -903,7 +903,7 @@ class Link(object):
 
     def __init__(self, url, comes_from=None, requires_python=None):
         """
-        Object representing a parsed link from https://pypi.python.org/simple/*
+        Object representing a parsed link from https://pypi.org/simple/*
 
         url:
             url of the resource pointed to (href of the link)
diff --git a/src/pip/_internal/models/index.py b/src/pip/_internal/models/index.py
--- a/src/pip/_internal/models/index.py
+++ b/src/pip/_internal/models/index.py
@@ -12,4 +12,4 @@ def url_to_path(self, path):
         return urllib_parse.urljoin(self.url, path)
 
 
-PyPI = Index('https://pypi.python.org/')
+PyPI = Index('https://pypi.org/')


Test patch:
diff --git a/tests/functional/test_install_config.py b/tests/functional/test_install_config.py
--- a/tests/functional/test_install_config.py
+++ b/tests/functional/test_install_config.py
@@ -24,10 +24,10 @@ def test_command_line_options_override_env_vars(script, virtualenv):
     Test that command line options override environmental variables.
 
     """
-    script.environ['PIP_INDEX_URL'] = 'https://b.pypi.python.org/simple/'
+    script.environ['PIP_INDEX_URL'] = 'https://example.com/simple/'
     result = script.pip('install', '-vvv', 'INITools', expect_error=True)
     assert (
-        "Getting page https://b.pypi.python.org/simple/initools"
+        "Getting page https://example.com/simple/initools"
         in result.stdout
     )
     virtualenv.clear()
@@ -36,7 +36,7 @@ def test_command_line_options_override_env_vars(script, virtualenv):
         'INITools',
         expect_error=True,
     )
-    assert "b.pypi.python.org" not in result.stdout
+    assert "example.com" not in result.stdout
     assert "Getting page https://download.zope.org/ppix" in result.stdout
 
 
@@ -85,24 +85,24 @@ def test_command_line_append_flags(script, virtualenv, data):
     variables.
 
     """
-    script.environ['PIP_FIND_LINKS'] = 'https://testpypi.python.org'
+    script.environ['PIP_FIND_LINKS'] = 'https://test.pypi.org'
     result = script.pip(
         'install', '-vvv', 'INITools', '--trusted-host',
-        'testpypi.python.org',
+        'test.pypi.org',
         expect_error=True,
     )
     assert (
-        "Analyzing links from page https://testpypi.python.org"
+        "Analyzing links from page https://test.pypi.org"
         in result.stdout
     ), str(result)
     virtualenv.clear()
     result = script.pip(
         'install', '-vvv', '--find-links', data.find_links, 'INITools',
-        '--trusted-host', 'testpypi.python.org',
+        '--trusted-host', 'test.pypi.org',
         expect_error=True,
     )
     assert (
-        "Analyzing links from page https://testpypi.python.org"
+        "Analyzing links from page https://test.pypi.org"
         in result.stdout
     )
     assert "Skipping link %s" % data.find_links in result.stdout
@@ -115,16 +115,16 @@ def test_command_line_appends_correctly(script, data):
 
     """
     script.environ['PIP_FIND_LINKS'] = (
-        'https://testpypi.python.org %s' % data.find_links
+        'https://test.pypi.org %s' % data.find_links
     )
     result = script.pip(
         'install', '-vvv', 'INITools', '--trusted-host',
-        'testpypi.python.org',
+        'test.pypi.org',
         expect_error=True,
     )
 
     assert (
-        "Analyzing links from page https://testpypi.python.org"
+        "Analyzing links from page https://test.pypi.org"
         in result.stdout
     ), result.stdout
     assert "Skipping link %s" % data.find_links in result.stdout
@@ -167,7 +167,7 @@ def _test_config_file_override_stack(script, virtualenv, config_file):
     result = script.pip('install', '-vvv', 'INITools', expect_error=True)
     assert "Getting page https://pypi.gocept.com/initools" in result.stdout
     result = script.pip(
-        'install', '-vvv', '--index-url', 'https://pypi.python.org/simple',
+        'install', '-vvv', '--index-url', 'https://pypi.org/simple/',
         'INITools',
         expect_error=True,
     )
@@ -177,7 +177,7 @@ def _test_config_file_override_stack(script, virtualenv, config_file):
     )
     assert "Getting page https://pypi.gocept.com/INITools" not in result.stdout
     assert (
-        "Getting page https://pypi.python.org/simple/initools" in result.stdout
+        "Getting page https://pypi.org/simple/initools" in result.stdout
     )
 
 
diff --git a/tests/functional/test_install_upgrade.py b/tests/functional/test_install_upgrade.py
--- a/tests/functional/test_install_upgrade.py
+++ b/tests/functional/test_install_upgrade.py
@@ -221,7 +221,7 @@ def test_uninstall_before_upgrade_from_url(script):
     )
     result2 = script.pip(
         'install',
-        'https://pypi.python.org/packages/source/I/INITools/INITools-'
+        'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
         '0.3.tar.gz',
         expect_error=True,
     )
@@ -243,7 +243,7 @@ def test_upgrade_to_same_version_from_url(script):
     )
     result2 = script.pip(
         'install',
-        'https://pypi.python.org/packages/source/I/INITools/INITools-'
+        'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
         '0.3.tar.gz',
         expect_error=True,
     )
@@ -373,7 +373,7 @@ def test_upgrade_vcs_req_with_dist_found(script):
     )
     script.pip("install", req, expect_stderr=True)
     result = script.pip("install", "-U", req, expect_stderr=True)
-    assert "pypi.python.org" not in result.stdout, result.stdout
+    assert "pypi.org" not in result.stdout, result.stdout
 
 
 class TestUpgradeDistributeToSetuptools(object):
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py
--- a/tests/functional/test_requests.py
+++ b/tests/functional/test_requests.py
@@ -8,10 +8,10 @@ def test_timeout(script):
         expect_error=True,
     )
     assert (
-        "Could not fetch URL https://pypi.python.org/simple/INITools/: "
+        "Could not fetch URL https://pypi.org/simple/INITools/: "
         "timed out" in result.stdout
     )
     assert (
-        "Could not fetch URL https://pypi.python.org/simple/: "
+        "Could not fetch URL https://pypi.org/simple/: "
         "timed out" in result.stdout
     )
diff --git a/tests/functional/test_search.py b/tests/functional/test_search.py
--- a/tests/functional/test_search.py
+++ b/tests/functional/test_search.py
@@ -73,6 +73,12 @@ def test_basic_search(script):
 
 
 @pytest.mark.network
+@pytest.mark.skip(
+    reason=("Warehouse search behavior is different and no longer returns "
+            "multiple results. See "
+            "https://github.com/pypa/warehouse/issues/3717 for more "
+            "information."),
+)
 def test_multiple_search(script):
     """
     Test searching for multiple packages at once.
@@ -100,7 +106,7 @@ def test_run_method_should_return_success_when_find_packages():
     Test SearchCommand.run for found package
     """
     command = SearchCommand()
-    cmdline = "--index=https://pypi.python.org/pypi pip"
+    cmdline = "--index=https://pypi.org/pypi pip"
     options, args = command.parse_args(cmdline.split())
     status = command.run(options, args)
     assert status == SUCCESS
@@ -112,7 +118,7 @@ def test_run_method_should_return_no_matches_found_when_does_not_find_pkgs():
     Test SearchCommand.run for no matches
     """
     command = SearchCommand()
-    cmdline = "--index=https://pypi.python.org/pypi nonexistentpackage"
+    cmdline = "--index=https://pypi.org/pypi nonexistentpackage"
     options, args = command.parse_args(cmdline.split())
     status = command.run(options, args)
     assert status == NO_MATCHES_FOUND
diff --git a/tests/scripts/test_all_pip.py b/tests/scripts/test_all_pip.py
--- a/tests/scripts/test_all_pip.py
+++ b/tests/scripts/test_all_pip.py
@@ -17,7 +17,7 @@
 
 
 def all_projects():
-    data = urllib_request.urlopen('http://pypi.python.org/simple/').read()
+    data = urllib_request.urlopen('http://pypi.org/simple/').read()
     projects = [m.group(1) for m in re.finditer(r'<a.*?>(.+)</a>', data)]
     return projects
 
diff --git a/tests/unit/test_finder.py b/tests/unit/test_finder.py
--- a/tests/unit/test_finder.py
+++ b/tests/unit/test_finder.py
@@ -107,7 +107,7 @@ def test_finder_detects_latest_already_satisfied_pypi_links():
     req.satisfied_by = satisfied_by
     finder = PackageFinder(
         [],
-        ["http://pypi.python.org/simple"],
+        ["http://pypi.org/simple/"],
         session=PipSession(),
     )
 
@@ -287,7 +287,7 @@ def test_finder_priority_file_over_page(data):
     req = InstallRequirement.from_line('gmpy==1.15', None)
     finder = PackageFinder(
         [data.find_links],
-        ["http://pypi.python.org/simple"],
+        ["http://pypi.org/simple/"],
         session=PipSession(),
     )
     all_versions = finder.find_all_candidates(req.name)
@@ -312,9 +312,10 @@ def test_finder_deplink():
         session=PipSession(),
     )
     finder.add_dependency_links(
-        ['https://pypi.python.org/packages/source/g/gmpy/gmpy-1.15.zip'])
+        ['https://files.pythonhosted.org/packages/source/g/gmpy/gmpy-1.15.zip']
+    )
     link = finder.find_requirement(req, False)
-    assert link.url.startswith("https://pypi"), link
+    assert link.url.startswith("https://files.pythonhosted.org/"), link
 
 
 @pytest.mark.network
@@ -325,17 +326,22 @@ def test_finder_priority_page_over_deplink():
     req = InstallRequirement.from_line('pip==1.5.6', None)
     finder = PackageFinder(
         [],
-        ["https://pypi.python.org/simple"],
+        ["https://pypi.org/simple/"],
         process_dependency_links=True,
         session=PipSession(),
     )
     finder.add_dependency_links([
-        'https://warehouse.python.org/packages/source/p/pip/pip-1.5.6.tar.gz'])
+        'https://files.pythonhosted.org/packages/source/p/pip/pip-1.5.6.tar.gz'
+    ])
     all_versions = finder.find_all_candidates(req.name)
     # Check that the dependency_link is last
-    assert all_versions[-1].location.url.startswith('https://warehouse')
+    assert all_versions[-1].location.url.startswith(
+        'https://files.pythonhosted.org/'
+    )
     link = finder.find_requirement(req, False)
-    assert link.url.startswith("https://pypi"), link
+    assert link.url.startswith(
+        "https://files.pythonhosted.org/packages/3f/08/7347ca4"
+    ), link
 
 
 def test_finder_priority_nonegg_over_eggfragments():
diff --git a/tests/unit/test_index.py b/tests/unit/test_index.py
--- a/tests/unit/test_index.py
+++ b/tests/unit/test_index.py
@@ -122,11 +122,11 @@ def warning(self, *args, **kwargs):
 @pytest.mark.parametrize(
     ("location", "trusted", "expected"),
     [
-        ("http://pypi.python.org/something", [], True),
-        ("https://pypi.python.org/something", [], False),
-        ("git+http://pypi.python.org/something", [], True),
-        ("git+https://pypi.python.org/something", [], False),
-        ("git+ssh://git@pypi.python.org/something", [], False),
+        ("http://pypi.org/something", [], True),
+        ("https://pypi.org/something", [], False),
+        ("git+http://pypi.org/something", [], True),
+        ("git+https://pypi.org/something", [], False),
+        ("git+ssh://git@pypi.org/something", [], False),
         ("http://localhost", [], False),
         ("http://127.0.0.1", [], False),
         ("http://example.com/something/", [], True),
diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py
--- a/tests/unit/test_req.py
+++ b/tests/unit/test_req.py
@@ -115,18 +115,19 @@ def test_missing_hash_checking(self):
         # This hash should be accepted because it came from the reqs file, not
         # from the internet:
         reqset.add_requirement(get_processed_req_from_line(
-            'https://pypi.python.org/packages/source/m/more-itertools/'
+            'https://files.pythonhosted.org/packages/source/m/more-itertools/'
             'more-itertools-1.0.tar.gz#md5=b21850c3cfa7efbb70fd662ab5413bdd',
             lineno=3,
         ))
         # The error text should list this as a URL and not `peep==3.1.1`:
         reqset.add_requirement(get_processed_req_from_line(
-            'https://pypi.python.org/packages/source/p/peep/peep-3.1.1.tar.gz',
+            'https://files.pythonhosted.org/'
+            'packages/source/p/peep/peep-3.1.1.tar.gz',
             lineno=4,
         ))
         finder = PackageFinder(
             [],
-            ['https://pypi.python.org/simple'],
+            ['https://pypi.org/simple/'],
             session=PipSession(),
         )
         resolver = self._basic_resolver(finder)
@@ -134,7 +135,7 @@ def test_missing_hash_checking(self):
             HashErrors,
             r'Hashes are required in --require-hashes mode, but they are '
             r'missing .*\n'
-            r'    https://pypi\.python\.org/packages/source/p/peep/peep'
+            r'    https://files\.pythonhosted\.org/packages/source/p/peep/peep'
             r'-3\.1\.1\.tar\.gz --hash=sha256:[0-9a-f]+\n'
             r'    blessings==1.0 --hash=sha256:[0-9a-f]+\n'
             r'THESE PACKAGES DO NOT MATCH THE HASHES.*\n'
diff --git a/tests/unit/test_unit_outdated.py b/tests/unit/test_unit_outdated.py
--- a/tests/unit/test_unit_outdated.py
+++ b/tests/unit/test_unit_outdated.py
@@ -14,7 +14,7 @@
 
 class MockPackageFinder(object):
 
-    BASE_URL = 'https://pypi.python.org/simple/pip-{0}.tar.gz'
+    BASE_URL = 'https://pypi.org/simple/pip-{0}.tar.gz'
     PIP_PROJECT_NAME = 'pip'
     INSTALLATION_CANDIDATES = [
         InstallationCandidate(PIP_PROJECT_NAME, '6.9.0',