0
  !   ˆÓ�þD7„³�ÈÌ­¼Ür4@?Ò„x_ÑÐ¿Î *‚    import collections
import os
import os.path
import subprocess
import sys
import sysconfig
import tempfile
from importlib import resources

def _ensurepip_is_disabled_in_debian_for_system():
    # Detect if ensurepip is being executed inside of a python-virtualenv
    # environment and return early if so.
    if hasattr(sys, 'real_prefix'):
        return

    # Detect if ensurepip is being executed inside of a stdlib venv
    # environment and return early if so.
    if sys.prefix != getattr(sys, "base_prefix", sys.prefix):
        return

    # If we've gotten here, then we are running inside of the system Python
    # and we don't want to use ensurepip to install into the system Python
    # so instead we'll redirect the user to using dpkg and apt-get.
    print('''\
ensurepip is disabled in Debian/Ubuntu for the system python.

Python modules for the system python are usually handled by dpkg and apt-get.

    apt install python3-<module name>

Install the python3-pip package to use pip itself.  Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.
''')
    sys.exit(1)


__all__ = ["version", "bootstrap"]
_PACKAGE_NAMES = ('setuptools', 'pip')
_SETUPTOOLS_VERSION = "65.5.0"
_PIP_VERSION = "22.3.1"
_PROJECTS = [
    ("setuptools", _SETUPTOOLS_VERSION, "py3"),
    ("pip", _PIP_VERSION, "py3"),
]

# Packages bundled in ensurepip._bundled have wheel_name set.
# Packages from WHEEL_PKG_DIR have wheel_path set.
_Package = collections.namedtuple('Package',
                                  ('version', 'wheel_name', 'wheel_path'))

# Directory of system wheel packages. Some Linux distribution packaging
# policies recommend against bundling dependencies. For example, Fedora
# installs wheel packages in the /usr/share/python-wheels/ directory and don't
# install the ensurepip._bundled package.
_WHEEL_PKG_DIR = sysconfig.get_config_var('WHEEL_PKG_DIR')


def _find_packages(path):
    packages = {}
    try:
        filenames = os.listdir(path)
    except OSError:
        # Ignore: path doesn't exist or permission error
        filenames = ()
    # Make the code deterministic if a directory contains multiple wheel files
    # of the same package, but don't attempt to implement correct version
    # comparison since this case should not happen.
    filenames = sorted(filenames)
    for filename in filenames:
        # filename is like 'pip-21.2.4-py3-none-any.whl'
        if not filename.endswith(".whl"):
            continue
        for name in _PACKAGE_NAMES:
            prefix = name + '-'
            if filename.startswith(prefix):
                break
        else:
            continue

        # Extract '21.2.4' from 'pip-21.2.4-py3-none-any.whl'
        version = filename.removeprefix(prefix).partition('-')[0]
        wheel_path = os.path.join(path, filename)
        packages[name] = _Package(version, None, wheel_path)
    return packages


def _get_packages():
    global _PACKAGES, _WHEEL_PKG_DIR
    if _PACKAGES is not None:
        return _PACKAGES

    packages = {}
    for name, version, py_tag in _PROJECTS:
        wheel_name = f"{name}-{version}-{py_tag}-none-any.whl"
        packages[name] = _Package(version, wheel_name, None)
    if _WHEEL_PKG_DIR:
        dir_packages = _find_packages(_WHEEL_PKG_DIR)
        # only used the wheel package directory if all packages are found there
        if all(name in dir_packages for name in _PACKAGE_NAMES):
            packages = dir_packages
    _PACKAGES = packages
    return packages
_PACKAGES = None


def _run_pip(args, additional_paths=None):
    # Run the bootstrapping in a subprocess to avoid leaking any state that happens
    # after pip has executed. Particularly, this avoids the case when pip holds onto
    # the files in *additional_paths*, preventing us to remove them at the end of the
    # invocation.
    code = f"""
import runpy
import sys
sys.path = {additional_paths or []} + sys.pa