Воркед
This commit is contained in:
1 parent
ac32c55ab9
commit
ee94d8e529
1138 files changed
+55771
-77901
No files matched your search
@@ -5,7 +5,7 @@ import logging
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
from typing import Any, Callable, Iterable, List, Optional, Tuple
|
||||
from typing import Iterable, List, Optional, Tuple
|
||||
|
||||
from pip._vendor.packaging.utils import canonicalize_name, canonicalize_version
|
||||
from pip._vendor.packaging.version import InvalidVersion, Version
|
||||
@@ -20,7 +20,7 @@ from pip._internal.operations.build.wheel_editable import build_wheel_editable
|
||||
from pip._internal.operations.build.wheel_legacy import build_wheel_legacy
|
||||
from pip._internal.req.req_install import InstallRequirement
|
||||
from pip._internal.utils.logging import indent_log
|
||||
from pip._internal.utils.misc import ensure_dir, hash_file, is_wheel_installed
|
||||
from pip._internal.utils.misc import ensure_dir, hash_file
|
||||
from pip._internal.utils.setuptools_build import make_setuptools_clean_args
|
||||
from pip._internal.utils.subprocess import call_subprocess
|
||||
from pip._internal.utils.temp_dir import TempDirectory
|
||||
@@ -31,7 +31,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
_egg_info_re = re.compile(r"([a-z0-9_.]+)-([a-z0-9_.!+-]+)", re.IGNORECASE)
|
||||
|
||||
BinaryAllowedPredicate = Callable[[InstallRequirement], bool]
|
||||
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
|
||||
|
||||
|
||||
@@ -46,7 +45,6 @@ def _contains_egg_info(s: str) -> bool:
|
||||
def _should_build(
|
||||
req: InstallRequirement,
|
||||
need_wheel: bool,
|
||||
check_binary_allowed: BinaryAllowedPredicate,
|
||||
) -> bool:
|
||||
"""Return whether an InstallRequirement should be built into a wheel."""
|
||||
if req.constraint:
|
||||
@@ -72,26 +70,7 @@ def _should_build(
|
||||
|
||||
if req.editable:
|
||||
# we only build PEP 660 editable requirements
|
||||
return req.supports_pyproject_editable()
|
||||
|
||||
if req.use_pep517:
|
||||
return True
|
||||
|
||||
if not check_binary_allowed(req):
|
||||
logger.info(
|
||||
"Skipping wheel build for %s, due to binaries being disabled for it.",
|
||||
req.name,
|
||||
)
|
||||
return False
|
||||
|
||||
if not is_wheel_installed():
|
||||
# we don't build legacy requirements if wheel is not installed
|
||||
logger.info(
|
||||
"Using legacy 'setup.py install' for %s, "
|
||||
"since package 'wheel' is not installed.",
|
||||
req.name,
|
||||
)
|
||||
return False
|
||||
return req.supports_pyproject_editable
|
||||
|
||||
return True
|
||||
|
||||
@@ -99,16 +78,13 @@ def _should_build(
|
||||
def should_build_for_wheel_command(
|
||||
req: InstallRequirement,
|
||||
) -> bool:
|
||||
return _should_build(req, need_wheel=True, check_binary_allowed=_always_true)
|
||||
return _should_build(req, need_wheel=True)
|
||||
|
||||
|
||||
def should_build_for_install_command(
|
||||
req: InstallRequirement,
|
||||
check_binary_allowed: BinaryAllowedPredicate,
|
||||
) -> bool:
|
||||
return _should_build(
|
||||
req, need_wheel=False, check_binary_allowed=check_binary_allowed
|
||||
)
|
||||
return _should_build(req, need_wheel=False)
|
||||
|
||||
|
||||
def _should_cache(
|
||||
@@ -159,24 +135,20 @@ def _get_cache_dir(
|
||||
return cache_dir
|
||||
|
||||
|
||||
def _always_true(_: Any) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def _verify_one(req: InstallRequirement, wheel_path: str) -> None:
|
||||
canonical_name = canonicalize_name(req.name or "")
|
||||
w = Wheel(os.path.basename(wheel_path))
|
||||
if canonicalize_name(w.name) != canonical_name:
|
||||
raise InvalidWheelFilename(
|
||||
"Wheel has unexpected file name: expected {!r}, "
|
||||
"got {!r}".format(canonical_name, w.name),
|
||||
f"Wheel has unexpected file name: expected {canonical_name!r}, "
|
||||
f"got {w.name!r}",
|
||||
)
|
||||
dist = get_wheel_distribution(FilesystemWheel(wheel_path), canonical_name)
|
||||
dist_verstr = str(dist.version)
|
||||
if canonicalize_version(dist_verstr) != canonicalize_version(w.version):
|
||||
raise InvalidWheelFilename(
|
||||
"Wheel has unexpected file name: expected {!r}, "
|
||||
"got {!r}".format(dist_verstr, w.version),
|
||||
f"Wheel has unexpected file name: expected {dist_verstr!r}, "
|
||||
f"got {w.version!r}",
|
||||
)
|
||||
metadata_version_value = dist.metadata_version
|
||||
if metadata_version_value is None:
|
||||
@@ -188,8 +160,7 @@ def _verify_one(req: InstallRequirement, wheel_path: str) -> None:
|
||||
raise UnsupportedWheel(msg)
|
||||
if metadata_version >= Version("1.2") and not isinstance(dist.version, Version):
|
||||
raise UnsupportedWheel(
|
||||
"Metadata 1.2 mandates PEP 440 version, "
|
||||
"but {!r} is not".format(dist_verstr)
|
||||
f"Metadata 1.2 mandates PEP 440 version, but {dist_verstr!r} is not"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user