Skip to content

Commit

Permalink
Merge pull request #5667 from pradyunsg/refactor/compat-to-utils
Browse files Browse the repository at this point in the history
Move pip._internal.compat to pip._internal.utils.compat
  • Loading branch information
pradyunsg authored Jul 29, 2018
2 parents 31a9e03 + abfe928 commit e818039
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/baseparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from pip._vendor.six import string_types

from pip._internal.compat import get_terminal_size
from pip._internal.configuration import Configuration, ConfigurationError
from pip._internal.utils.compat import get_terminal_size

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from pip._vendor.packaging.utils import canonicalize_name

from pip._internal import index
from pip._internal.compat import expanduser
from pip._internal.download import path_to_url
from pip._internal.models.link import Link
from pip._internal.utils.compat import expanduser
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.wheel import InvalidWheelFilename, Wheel

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from pip._internal import index
from pip._internal.basecommand import Command
from pip._internal.cache import WheelCache
from pip._internal.compat import stdlib_pkgs
from pip._internal.operations.freeze import freeze
from pip._internal.utils.compat import stdlib_pkgs

DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from pip._vendor.six.moves import xmlrpc_client # type: ignore

from pip._internal.basecommand import SUCCESS, Command
from pip._internal.compat import get_terminal_size
from pip._internal.download import PipXmlrpcTransport
from pip._internal.exceptions import CommandError
from pip._internal.models.index import PyPI
from pip._internal.status_codes import NO_MATCHES_FOUND
from pip._internal.utils.compat import get_terminal_size
from pip._internal.utils.logging import indent_log

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request

from pip._internal.compat import ipaddress
from pip._internal.download import HAS_TLS, is_url, path_to_url, url_to_path
from pip._internal.exceptions import (
BestVersionAlreadyInstalled, DistributionNotFound, InvalidWheelFilename,
Expand All @@ -30,6 +29,7 @@
from pip._internal.models.index import PyPI
from pip._internal.models.link import Link
from pip._internal.pep425tags import get_supported
from pip._internal.utils.compat import ipaddress
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from distutils import sysconfig as distutils_sysconfig
from distutils.command.install import SCHEME_KEYS # type: ignore

from pip._internal.compat import WINDOWS, expanduser
from pip._internal.utils import appdirs
from pip._internal.utils.compat import WINDOWS, expanduser

# Application Directories
USER_CACHE_DIR = appdirs.user_cache_dir("pip")
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from pip._vendor import pkg_resources, requests

from pip._internal.build_env import BuildEnvironment
from pip._internal.compat import expanduser
from pip._internal.download import (
is_dir_url, is_file_url, is_vcs_url, unpack_url, url_to_path,
)
from pip._internal.exceptions import (
DirectoryUrlHashUnsupported, HashUnpinned, InstallationError,
PreviousBuildDirError, VcsHashUnsupported,
)
from pip._internal.utils.compat import expanduser
from pip._internal.utils.hashes import MissingHashes
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import display_path, normalize_path
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from pip._internal import wheel
from pip._internal.build_env import NoOpBuildEnvironment
from pip._internal.compat import native_str
from pip._internal.download import (
is_archive_file, is_url, path_to_url, url_to_path,
)
Expand All @@ -34,6 +33,7 @@
from pip._internal.models.index import PyPI, TestPyPI
from pip._internal.models.link import Link
from pip._internal.req.req_uninstall import UninstallPathSet
from pip._internal.utils.compat import native_str
from pip._internal.utils.hashes import Hashes
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/req/req_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from pip._vendor import pkg_resources

from pip._internal.compat import WINDOWS, cache_from_source, uses_pycache
from pip._internal.exceptions import UninstallationError
from pip._internal.locations import bin_py, bin_user
from pip._internal.utils.compat import WINDOWS, cache_from_source, uses_pycache
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
FakeFile, ask, dist_in_usersite, dist_is_local, egg_link_path, is_local,
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pip._vendor.six import PY2, text_type

from pip._internal.compat import WINDOWS, expanduser
from pip._internal.utils.compat import WINDOWS, expanduser


def user_cache_dir(appname):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/filesystem.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import os.path

from pip._internal.compat import get_path_uid
from pip._internal.utils.compat import get_path_uid


def check_path_owner(path):
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging.handlers
import os

from pip._internal.compat import WINDOWS
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.misc import ensure_dir

try:
Expand Down
6 changes: 3 additions & 3 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
from pip._vendor.six.moves import input
from pip._vendor.six.moves.urllib import parse as urllib_parse

from pip._internal.compat import (
WINDOWS, console_to_str, expanduser, stdlib_pkgs,
)
from pip._internal.exceptions import CommandError, InstallationError
from pip._internal.locations import (
running_under_virtualenv, site_packages, user_site, virtualenv_no_global,
write_delete_marker_file,
)
from pip._internal.utils.compat import (
WINDOWS, console_to_str, expanduser, stdlib_pkgs,
)

if PY2:
from io import BytesIO as StringIO
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from pip._vendor import lockfile, pkg_resources
from pip._vendor.packaging import version as packaging_version

from pip._internal.compat import WINDOWS
from pip._internal.index import PackageFinder
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.misc import ensure_dir, get_installed_version

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pip._vendor.progress.helpers import HIDE_CURSOR, SHOW_CURSOR, WritelnMixin
from pip._vendor.progress.spinner import Spinner

from pip._internal.compat import WINDOWS
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.logging import get_indentation
from pip._internal.utils.misc import format_size
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request

from pip._internal.compat import samefile
from pip._internal.exceptions import BadCommand
from pip._internal.utils.compat import samefile
from pip._internal.utils.misc import display_path
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.vcs import VersionControl, vcs
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _check_cryptography(cryptography_version):
RequestsDependencyWarning)

# Attempt to enable urllib3's SNI support, if possible
from pip._internal.compat import WINDOWS
from pip._internal.utils.compat import WINDOWS
if not WINDOWS:
try:
from pip._vendor.urllib3.contrib import pyopenssl
Expand Down
2 changes: 1 addition & 1 deletion tasks/vendoring/patches/requests.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ index 9c3b769..36a4ef40 100644
- _check_cryptography(cryptography_version)
-except ImportError:
- pass
+from pip._internal.compat import WINDOWS
+from pip._internal.utils.compat import WINDOWS
+if not WINDOWS:
+ try:
+ from pip._vendor.urllib3.contrib import pyopenssl
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_install_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from pip._internal.compat import cache_from_source, uses_pycache
from pip._internal.utils.compat import cache_from_source, uses_pycache
from tests.lib import pyversion
from tests.lib.local_repos import local_checkout

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pip._internal.cache import WheelCache
from pip._internal.compat import expanduser
from pip._internal.utils.compat import expanduser


class TestWheelCache:
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import pytest

import pip._internal.compat
from pip._internal.compat import (
import pip._internal.utils.compat as pip_compat
from pip._internal.utils.compat import (
console_to_str, expanduser, get_path_uid, native_str,
)

Expand Down Expand Up @@ -64,7 +64,7 @@ def check_warning(msg, *args, **kwargs):
"Subprocess output does not appear to be encoded as")

monkeypatch.setattr(locale, 'getpreferredencoding', lambda: 'utf-8')
monkeypatch.setattr(pip._internal.compat.logger, 'warning', check_warning)
monkeypatch.setattr(pip_compat.logger, 'warning', check_warning)
console_to_str(some_bytes)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pip._vendor.packaging.requirements import Requirement

from pip._internal import pep425tags, wheel
from pip._internal.compat import WINDOWS
from pip._internal.exceptions import InvalidWheelFilename, UnsupportedWheel
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.misc import unpack_file
from tests.lib import DATA_DIR

Expand Down

0 comments on commit e818039

Please sign in to comment.