Skip to content

Commit

Permalink
Remove support for git+git@ pseudo VCS URLs.
Browse files Browse the repository at this point in the history
Now that we don't need to support git@
pseudo-urls, we can simplify the test for
valid VCS URLs based on link.is_vcs, which
is turns is based on the URL scheme.

This also means we fail earlier if a git@ pseudo
URL is used.

Since VCS requirements are not validated to be URLs
in Requirement constructors, we can simplify update_editable.
  • Loading branch information
sbidoul committed Jan 9, 2021
1 parent f54e9ae commit 9e95016
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 42 deletions.
2 changes: 2 additions & 0 deletions news/7554.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed support for VCS pseudo URLs editable requirements. It was
emitting deprecation warning since version 20.0.
15 changes: 4 additions & 11 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,17 @@ def parse_editable(editable_req):
url = f'{version_control}+{url}'
break

if '+' not in url:
link = Link(url)

if not link.is_vcs:
backends = ", ".join([backend.name + '+' for backend in vcs.backends])
raise InstallationError(
f'{editable_req} is not a valid editable requirement. '
f'It should either be a path to a local project or a VCS URL '
f'(beginning with {backends}).'
)

vc_type = url.split('+', 1)[0].lower()

if not vcs.get_backend(vc_type):
backends = ", ".join([bends.name + '+URL' for bends in vcs.backends])
error_message = "For --editable={}, " \
"only {} are currently supported".format(
editable_req, backends)
raise InstallationError(error_message)

package_name = Link(url).egg_fragment
package_name = link.egg_fragment
if not package_name:
raise InstallationError(
"Could not detect requirement name for '{}', please specify one "
Expand Down
35 changes: 8 additions & 27 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,34 +625,15 @@ def update_editable(self, obtain=True):
if self.link.scheme == 'file':
# Static paths don't get updated
return
assert '+' in self.link.url, \
"bad url: {self.link.url!r}".format(**locals())
vc_type, url = self.link.url.split('+', 1)
vcs_backend = vcs.get_backend(vc_type)
if vcs_backend:
if not self.link.is_vcs:
reason = (
"This form of VCS requirement is being deprecated: {}."
).format(
self.link.url
)
replacement = None
if self.link.url.startswith("git+git@"):
replacement = (
"git+https://[email protected]/..., "
"git+ssh://[email protected]/..., "
"or the insecure git+git://[email protected]/..."
)
deprecated(reason, replacement, gone_in="21.0", issue=7554)
hidden_url = hide_url(self.link.url)
if obtain:
vcs_backend.obtain(self.source_dir, url=hidden_url)
else:
vcs_backend.export(self.source_dir, url=hidden_url)
vcs_backend = vcs.get_backend_for_scheme(self.link.scheme)
# Editable requirements are validated in Requirement constructors,
# if it's neither a path nor a valid VCS URL, it's a bug.
assert vcs_backend, f"Unsupported VCS URL {self.link.url}"
hidden_url = hide_url(self.link.url)
if obtain:
vcs_backend.obtain(self.source_dir, url=hidden_url)
else:
assert 0, (
'Unexpected version control type (in {}): {}'.format(
self.link, vc_type))
vcs_backend.export(self.source_dir, url=hidden_url)

# Top-level Actions
def uninstall(self, auto_confirm=False, verbose=False):
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Bazaar(VersionControl):
repo_name = 'branch'
schemes = (
'bzr', 'bzr+http', 'bzr+https', 'bzr+ssh', 'bzr+sftp', 'bzr+ftp',
'bzr+lp',
'bzr+lp', 'bzr+file'
)

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion src/pip/_internal/vcs/subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class Subversion(VersionControl):
name = 'svn'
dirname = '.svn'
repo_name = 'checkout'
schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+https', 'svn+svn')
schemes = (
'svn', 'svn+ssh', 'svn+http', 'svn+https', 'svn+svn', 'svn+file'
)

@classmethod
def should_add_vcs_url_prefix(cls, remote_url):
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/test_install_vcs_git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from pip._internal.utils.urls import path_to_url
from tests.lib import pyversion # noqa: F401
from tests.lib import (
_change_test_package_version,
Expand Down Expand Up @@ -454,7 +455,7 @@ def test_check_submodule_addition(script):
)

install_result = script.pip(
'install', '-e', 'git+' + module_path + '#egg=version_pkg'
'install', '-e', 'git+' + path_to_url(module_path) + '#egg=version_pkg'
)
install_result.did_create(
script.venv / 'src/version-pkg/testpkg/static/testfile'
Expand All @@ -467,7 +468,7 @@ def test_check_submodule_addition(script):

# expect error because git may write to stderr
update_result = script.pip(
'install', '-e', 'git+' + module_path + '#egg=version_pkg',
'install', '-e', 'git+' + path_to_url(module_path) + '#egg=version_pkg',
'--upgrade',
)

Expand Down

0 comments on commit 9e95016

Please sign in to comment.