Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove from pip/_internal/__init__.py the vcs module imports #6545

Merged
merged 2 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -931,6 +932,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
Loading