Skip to content

Commit

Permalink
Merge pull request #6545 from cjerdonek/vcs-imports
Browse files Browse the repository at this point in the history
Remove from pip/_internal/__init__.py the vcs module imports
  • Loading branch information
cjerdonek committed Jun 3, 2019
2 parents dd72011 + 5c89643 commit ce46f85
Show file tree
Hide file tree
Showing 14 changed files with 660 additions and 649 deletions.
1 change: 0 additions & 1 deletion src/pip/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from pip._internal.commands import commands_dict
from pip._internal.exceptions import PipError
from pip._internal.utils import deprecation
from pip._internal.vcs import git, mercurial, subversion, bazaar # noqa
from pip._vendor.urllib3.exceptions import InsecureRequestWarning

logger = logging.getLogger(__name__)
Expand Down
17 changes: 3 additions & 14 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS, ask, ask_input, ask_password, ask_path_exists,
backup_dir, consume, display_path, format_size, get_installed_version,
remove_auth_from_url, rmtree, split_auth_netloc_from_url, splitext,
unpack_file,
path_to_url, remove_auth_from_url, rmtree, split_auth_netloc_from_url,
splitext, unpack_file,
)
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Expand All @@ -52,7 +52,7 @@
from optparse import Values
from pip._internal.models.link import Link
from pip._internal.utils.hashes import Hashes
from pip._internal.vcs import AuthInfo, VersionControl
from pip._internal.vcs.versioncontrol import AuthInfo, VersionControl

try:
import ssl # noqa
Expand Down Expand Up @@ -693,17 +693,6 @@ def url_to_path(url):
return path


def path_to_url(path):
# type: (Union[str, Text]) -> str
"""
Convert a path to a file: URL. The path will be made absolute and have
quoted path parts.
"""
path = os.path.normpath(os.path.abspath(path))
url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path))
return url


def is_archive_file(name):
# type: (str) -> bool
"""Return True if `name` is a considered as an archive file."""
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def _match_vcs_scheme(url):
Returns the matched VCS scheme, or None if there's no match.
"""
from pip._internal.vcs import VcsSupport
for scheme in VcsSupport.schemes:
from pip._internal.vcs import vcs
for scheme in vcs.schemes:
if url.lower().startswith(scheme) and url[len(scheme)] in '+:':
return scheme
return None
Expand Down
12 changes: 12 additions & 0 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pip._vendor.six import PY2
from pip._vendor.six.moves import input, shlex_quote
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request
from pip._vendor.six.moves.urllib.parse import unquote as urllib_unquote

from pip._internal.exceptions import CommandError, InstallationError
Expand Down Expand Up @@ -941,6 +942,17 @@ def enum(*sequential, **named):
return type('Enum', (), enums)


def path_to_url(path):
# type: (Union[str, Text]) -> str
"""
Convert a path to a file: URL. The path will be made absolute and have
quoted path parts.
"""
path = os.path.normpath(os.path.abspath(path))
url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path))
return url


def split_auth_from_netloc(netloc):
"""
Parse out and remove the auth information from a netloc.
Expand Down

0 comments on commit ce46f85

Please sign in to comment.