(*, root=None, upgrade=False, user=False,
              altinstall=False, default_pip=False,
              verbosity=0)
Bootstrap pip into the current Python installation (or the given root
    directory). Returns pip command status code.

    Note that calling this function will alter both sys.path and os.environ.
Bootstrap pip into the current Python installation (or the given root
    directory). Returns pip command status code.
Bootstrap pip into the current Python installation ( or the given root directory ) . Returns pip command status code .
def _bootstrap(*, root=None, upgrade=False, user=False,
              altinstall=False, default_pip=False,
              verbosity=0):
    """
    Bootstrap pip into the current Python installation (or the given root
    directory). Returns pip command status code.

    Note that calling this function will alter both sys.path and os.environ.
    """
    if altinstall and default_pip:
        raise ValueError("Cannot use altinstall and default_pip together")

    sys.audit("ensurepip.bootstrap", root)

    _disable_pip_configuration_settings()

    # By default, installing pip and setuptools installs all of the
    # following scripts (X.Y == running Python version):
    #
    #   pip, pipX, pipX.Y, easy_install, easy_install-X.Y
    #
    # pip 1.5+ allows ensurepip to request that some of those be left out
    if altinstall:
        # omit pip, pipX and easy_install
        os.environ["ENSUREPIP_OPTIONS"] = "altinstall"
    elif not default_pip:
        # omit pip and easy_install
        os.environ["ENSUREPIP_OPTIONS"] = "install"

    with tempfile.TemporaryDirectory() as tmpdir:
        # Put our bundled wheels into a temporary directory and construct the
        # additional paths that need added to sys.path
        additional_paths = []
        for name, package in _get_packages().items():
            if package.wheel_name:
                # Use bundled wheel package
                from ensurepip import _bundled
                wheel_name = package.wheel_name
                whl = resources.read_binary(_bundled, wheel_name)
            else:
                # Use the wheel package directory
                with open(package.wheel_path, "rb") as fp:
                    whl = fp.read()
                wheel_name = os.path.basename(package.wheel_path)

            filename = os.path.join(tmpdir, wheel_name)
            with open(filename, "wb") as fp:
                fp.write(whl)

            additional_paths.append(filename)

        # Construct the arguments to be passed to the pip command
        args = ["install", "--no-cache-dir", "--no-index", "--find-links", tmpdir]
        if root:
            args += ["--root", root]
        if upgrade:
            args += ["--upgrade"]
        if user:
            args += ["--user"]
        if verbosity:
            args += ["-" + "v" * verbosity]

        return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
def _bootstrap ( * , root = None , upgrade = False , user = False , altinstall = False , default_pip = False , verbosity = 0 ) : if altinstall and default_pip : raise ValueError ( "Cannot use altinstall and default_pip together" ) sys . audit ( "ensurepip.bootstrap" , root ) _disable_pip_configuration_settings ( ) # By default, installing pip and setuptools installs all of the # following scripts (X.Y == running Python version): # #   pip, pipX, pipX.Y, easy_install, easy_install-X.Y # # pip 1.5+ allows ensurepip to request that some of those be left out if altinstall : # omit pip, pipX and easy_install os . environ [ "ENSUREPIP_OPTIONS" ] = "altinstall" elif not default_pip : # omit pip and easy_install os . environ [ "ENSUREPIP_OPTIONS" ] = "install" with tempfile . TemporaryDirectory ( ) as tmpdir : # Put our bundled wheels into a temporary directory and construct the # additional paths that need added to sys.path additional_paths = [ ] for name , package in _get_packages ( ) . items ( ) : if package . wheel_name : # Use bundled wheel package from ensurepip import _bundled wheel_name = package . wheel_name whl = resources . read_binary ( _bundled , wheel_name ) else : # Use the wheel package directory with open ( package . wheel_path , "rb" ) as fp : whl = fp . read ( ) wheel_name = os . path . basename ( package . wheel_path ) filename = os . path . join ( tmpdir , wheel_name ) with open ( filename , "wb" ) as fp : fp . write ( whl ) additional_paths . append ( filename ) # Construct the arguments to be passed to the pip command args = [ "install" , "--no-cache-dir" , "--no-index" , "--find-links" , tmpdir ] if root : args += [ "--root" , root ] if upgrade : args += [ "--upgrade" ] if user : args += [ "--user" ] if verbosity : args += [ "-" + "v" * verbosity ] return _run_pip ( [ * args , * _PACKAGE_NAMES ] , additional_paths )