0
  7   ˆl–Ãa¾”Ò~êqAão\jbÑ¿‘äÇò 8à##n¶2Ž?Äƒh¹ÉÁÆ      512
  Z   ˆl–Ým_Jõ0–52 Z¸î2Ê˜´o�þYd.¬Ü­€¬‘¦„ë@þÅ„ uÿÊ_ŠI|¥�+Wé3ž¯a–Ãa¾”Ò~êqAão\ŠbÑ¿É 3    """Orchestrator for building wheels from InstallRequirements.
"""

import logging
import os.path
import re
import shutil
from typing import Callable, Iterable, List, Optional, Tuple

from pip._vendor.packaging.utils import canonicalize_name, canonicalize_version
from pip._vendor.packaging.version import InvalidVersion, Version

from pip._internal.cache import WheelCache
from pip._internal.exceptions import InvalidWheelFilename, UnsupportedWheel
from pip._internal.metadata import FilesystemWheel, get_wheel_distribution
from pip._internal.models.link import Link
from pip._internal.models.wheel import Wheel
from pip._internal.operations.build.wheel import build_wheel_pep517
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.deprecation import (
    LegacyInstallReasonMissingWheelPackage,
    LegacyInstallReasonNoBinaryForcesSetuptoolsInstall,
)
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.setuptools_build import make_setuptools_clean_args
from pip._internal.utils.subprocess import call_subprocess
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.urls import path_to_url
from pip._internal.vcs import vcs

logger = logging.getLogger(__name__)

_egg_info_re = re.compile(r"([a-z0-9_.]+)-([a-z0-9_.!+-]+)", re.IGNORECASE)

BdistWheelAllowedPredicate = Callable[[InstallRequirement], bool]
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]


def _contains_egg_info(s: str) -> bool:
    """Determine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    """
    return bool(_egg_info_re.search(s))


def _should_build(
    req: InstallRequirement,
    need_wheel: bool,
    check_bdist_wheel: Optional[BdistWheelAllowedPredicate] = None,
) -> bool:
    """Return whether an InstallRequirement should be built into a wheel."""
    if req.constraint:
        # never build requirements that are merely constraints
        return False
    if req.is_wheel:
        if need_wheel:
            logger.info(
                "Skipping %s, due to already being wheel.",
                req.name,
            )
        return False

    if need_wheel:
        # i.e. pip wheel, not pip install
        return True

    # From this point, this concerns the pip install command only
    # (need_wheel=False).

    if not req.source_dir:
        return False

    if req.editable:
        # we only build PEP 660 editable requirements
        return req.supports_pyproject_editable()

    if req.use_pep517:
        return True

    assert check_bdist_wheel is not None
    if not check_bdist_wheel(req):
        # /!\ When we change this to unconditionally return True, we must also remove
        # support for `--install-option`. Indeed, `--install-option` implies
        # `--no-binary` so we can return False here and run `setup.py install`.
        # `--global-option` and `--build-option` can remain until we drop support for
        # building with `setup.py bdist_wheel`.
        req.legacy_install_reason = LegacyInstallReasonNoBinaryForcesSetuptoolsInstall
        return False

    if not is_wheel_installed():
        # we don't build legacy requirements if wheel is not installed
        req.legacy_install_reason = LegacyInstallReasonMissingWheelPackage
        return False

    return True


def should_build_for_wheel_command(
    req: InstallRequirement,
) -> bool:
    return _should_build(req, need_wheel=True)


def should_build_for_install_command(
    req: InstallRequirement,
    check_bdist_wheel_allowed: BdistWheelAllowedPredicate,
) -> bool:
    return _should_build(
        req, need_whee