Пример #1
0
def pip_import_string(python_exe):
    os_utils = OSUtils()
    cmd = [python_exe, "-c", "import pip; print(pip.__version__)"]
    p = os_utils.popen(cmd,
                       stdout=os_utils.pipe,
                       stderr=os_utils.pipe,
                       env=os_utils.original_environ())
    stdout, stderr = p.communicate()
    if not p.returncode == 0:
        raise MissingPipError(python_path=python_exe)
    pip_version = stdout.decode("utf-8").strip()
    pip_major_version = int(pip_version.split(".")[0])
    pip_minor_version = int(pip_version.split(".")[1])

    # Pip moved its internals to an _internal module in version 10.
    # In order to be compatible with version 9 which has it at at the
    # top level we need to figure out the correct import path here.
    if pip_major_version == 9:
        return "from pip import main"
    # Pip changed their import structure again in 19.3
    # https://github.com/pypa/pip/commit/09fd200
    elif (pip_major_version, pip_minor_version) >= (19, 3):
        return "from pip._internal.main import main"
    else:
        return "from pip._internal import main"
def pip_import_string(python_exe):
    os_utils = OSUtils()
    cmd = [
        python_exe,
        "-c",
        "import pip; assert int(pip.__version__.split('.')[0]) <= 9"
    ]
    p = os_utils.popen(cmd,stdout=os_utils.pipe, stderr=os_utils.pipe)
    p.communicate()
    # Pip moved its internals to an _internal module in version 10.
    # In order to be compatible with version 9 which has it at at the
    # top level we need to figure out the correct import path here.
    if p.returncode == 0:
        return 'from pip import main'
    else:
        return 'from pip._internal import main'
Пример #3
0
def pip_import_string(python_exe):
    os_utils = OSUtils()
    cmd = [python_exe, "-c", "import pip; print(pip.__version__)"]
    p = os_utils.popen(cmd, stdout=os_utils.pipe, stderr=os_utils.pipe)
    stdout, stderr = p.communicate()
    pip_version = stdout.decode('utf-8').strip()
    pip_major_version = int(pip_version.split('.')[0])
    pip_minor_version = int(pip_version.split('.')[1])

    # Pip moved its internals to an _internal module in version 10.
    # In order to be compatible with version 9 which has it at at the
    # top level we need to figure out the correct import path here.
    if pip_major_version == 9:
        return 'from pip import main'
    # Pip changed their import structure again in 19.3
    # https://github.com/pypa/pip/commit/09fd200
    elif pip_major_version >= 19 and pip_minor_version >= 3:
        return 'from pip._internal.main import main'
    else:
        return 'from pip._internal import main'