Skip to content

Commit fc62b5b

Browse files
committed
Move wheel extension information to remove cycle imports
1 parent 41f87fb commit fc62b5b

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/pip/_internal/index.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
from pip._internal.utils.deprecation import deprecated
3535
from pip._internal.utils.logging import indent_log
3636
from pip._internal.utils.misc import (
37-
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, normalize_path,
37+
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, WHEEL_EXTENSION, normalize_path,
3838
redact_password_from_url,
3939
)
4040
from pip._internal.utils.packaging import check_requires_python
41-
from pip._internal.wheel import Wheel, wheel_ext
41+
from pip._internal.wheel import Wheel
4242

4343
__all__ = ['FormatControl', 'PackageFinder']
4444

@@ -781,15 +781,15 @@ def _link_package_versions(self, link, search):
781781
link, 'unsupported archive format: %s' % ext,
782782
)
783783
return
784-
if "binary" not in search.formats and ext == wheel_ext:
784+
if "binary" not in search.formats and ext == WHEEL_EXTENSION:
785785
self._log_skipped_link(
786786
link, 'No binaries permitted for %s' % search.supplied,
787787
)
788788
return
789789
if "macosx10" in link.path and ext == '.zip':
790790
self._log_skipped_link(link, 'macosx10 one')
791791
return
792-
if ext == wheel_ext:
792+
if ext == WHEEL_EXTENSION:
793793
try:
794794
wheel = Wheel(link.filename)
795795
except InvalidWheelFilename:
@@ -808,7 +808,7 @@ def _link_package_versions(self, link, search):
808808
version = wheel.version
809809

810810
# This should be up by the search.ok_binary check, but see issue 2700.
811-
if "source" not in search.formats and ext != wheel_ext:
811+
if "source" not in search.formats and ext != WHEEL_EXTENSION:
812812
self._log_skipped_link(
813813
link, 'No sources permitted for %s' % search.supplied,
814814
)

src/pip/_internal/models/link.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from pip._vendor.six.moves.urllib import parse as urllib_parse
55

66
from pip._internal.download import path_to_url
7-
from pip._internal.utils.misc import redact_password_from_url, splitext
7+
from pip._internal.utils.misc import (
8+
WHEEL_EXTENSION, redact_password_from_url, splitext,
9+
)
810
from pip._internal.utils.models import KeyBasedCompareMixin
9-
from pip._internal.wheel import wheel_ext
1011

1112

1213
class Link(KeyBasedCompareMixin):
@@ -126,7 +127,7 @@ def show_url(self):
126127

127128
@property
128129
def is_wheel(self):
129-
return self.ext == wheel_ext
130+
return self.ext == WHEEL_EXTENSION
130131

131132
@property
132133
def is_artifact(self):

src/pip/_internal/utils/misc.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,21 @@
5050
'renames', 'get_prog',
5151
'unzip_file', 'untar_file', 'unpack_file', 'call_subprocess',
5252
'captured_stdout', 'ensure_dir',
53-
'ARCHIVE_EXTENSIONS', 'SUPPORTED_EXTENSIONS',
53+
'ARCHIVE_EXTENSIONS', 'SUPPORTED_EXTENSIONS', 'WHEEL_EXTENSION',
5454
'get_installed_version', 'remove_auth_from_url']
5555

5656

5757
logger = std_logging.getLogger(__name__)
5858

59+
WHEEL_EXTENSION = '.whl'
5960
BZ2_EXTENSIONS = ('.tar.bz2', '.tbz')
6061
XZ_EXTENSIONS = ('.tar.xz', '.txz', '.tlz', '.tar.lz', '.tar.lzma')
61-
ZIP_EXTENSIONS = ('.zip', '.whl')
62+
ZIP_EXTENSIONS = ('.zip', WHEEL_EXTENSION)
6263
TAR_EXTENSIONS = ('.tar.gz', '.tgz', '.tar')
6364
ARCHIVE_EXTENSIONS = (
6465
ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS)
6566
SUPPORTED_EXTENSIONS = ZIP_EXTENSIONS + TAR_EXTENSIONS
67+
6668
try:
6769
import bz2 # noqa
6870
SUPPORTED_EXTENSIONS += BZ2_EXTENSIONS

src/pip/_internal/wheel.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
if MYPY_CHECK_RUNNING:
4444
from typing import Dict, List, Optional # noqa: F401
4545

46-
wheel_ext = '.whl'
47-
4846
VERSION_COMPATIBLE = (1, 0)
4947

5048

0 commit comments

Comments
 (0)