Skip to content

Commit

Permalink
Move wheel extension information to remove cycle imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Nov 30, 2018
1 parent 41f87fb commit fc62b5b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, normalize_path,
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, WHEEL_EXTENSION, normalize_path,
redact_password_from_url,
)
from pip._internal.utils.packaging import check_requires_python
from pip._internal.wheel import Wheel, wheel_ext
from pip._internal.wheel import Wheel

__all__ = ['FormatControl', 'PackageFinder']

Expand Down Expand Up @@ -781,15 +781,15 @@ def _link_package_versions(self, link, search):
link, 'unsupported archive format: %s' % ext,
)
return
if "binary" not in search.formats and ext == wheel_ext:
if "binary" not in search.formats and ext == WHEEL_EXTENSION:
self._log_skipped_link(
link, 'No binaries permitted for %s' % search.supplied,
)
return
if "macosx10" in link.path and ext == '.zip':
self._log_skipped_link(link, 'macosx10 one')
return
if ext == wheel_ext:
if ext == WHEEL_EXTENSION:
try:
wheel = Wheel(link.filename)
except InvalidWheelFilename:
Expand All @@ -808,7 +808,7 @@ def _link_package_versions(self, link, search):
version = wheel.version

# This should be up by the search.ok_binary check, but see issue 2700.
if "source" not in search.formats and ext != wheel_ext:
if "source" not in search.formats and ext != WHEEL_EXTENSION:
self._log_skipped_link(
link, 'No sources permitted for %s' % search.supplied,
)
Expand Down
7 changes: 4 additions & 3 deletions src/pip/_internal/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from pip._vendor.six.moves.urllib import parse as urllib_parse

from pip._internal.download import path_to_url
from pip._internal.utils.misc import redact_password_from_url, splitext
from pip._internal.utils.misc import (
WHEEL_EXTENSION, redact_password_from_url, splitext,
)
from pip._internal.utils.models import KeyBasedCompareMixin
from pip._internal.wheel import wheel_ext


class Link(KeyBasedCompareMixin):
Expand Down Expand Up @@ -126,7 +127,7 @@ def show_url(self):

@property
def is_wheel(self):
return self.ext == wheel_ext
return self.ext == WHEEL_EXTENSION

@property
def is_artifact(self):
Expand Down
6 changes: 4 additions & 2 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,21 @@
'renames', 'get_prog',
'unzip_file', 'untar_file', 'unpack_file', 'call_subprocess',
'captured_stdout', 'ensure_dir',
'ARCHIVE_EXTENSIONS', 'SUPPORTED_EXTENSIONS',
'ARCHIVE_EXTENSIONS', 'SUPPORTED_EXTENSIONS', 'WHEEL_EXTENSION',
'get_installed_version', 'remove_auth_from_url']


logger = std_logging.getLogger(__name__)

WHEEL_EXTENSION = '.whl'
BZ2_EXTENSIONS = ('.tar.bz2', '.tbz')
XZ_EXTENSIONS = ('.tar.xz', '.txz', '.tlz', '.tar.lz', '.tar.lzma')
ZIP_EXTENSIONS = ('.zip', '.whl')
ZIP_EXTENSIONS = ('.zip', WHEEL_EXTENSION)
TAR_EXTENSIONS = ('.tar.gz', '.tgz', '.tar')
ARCHIVE_EXTENSIONS = (
ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS)
SUPPORTED_EXTENSIONS = ZIP_EXTENSIONS + TAR_EXTENSIONS

try:
import bz2 # noqa
SUPPORTED_EXTENSIONS += BZ2_EXTENSIONS
Expand Down
2 changes: 0 additions & 2 deletions src/pip/_internal/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
if MYPY_CHECK_RUNNING:
from typing import Dict, List, Optional # noqa: F401

wheel_ext = '.whl'

VERSION_COMPATIBLE = (1, 0)


Expand Down

0 comments on commit fc62b5b

Please sign in to comment.