Python pip._internal() Examples

The following are 6 code examples of pip._internal(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pip , or try the search function .
Example #1
Source File: compat.py    From chalice with Apache License 2.0 6 votes vote down vote up
def pip_import_string():
    # type: () -> str
    import pip
    pip_major_version = int(pip.__version__.split('.')[0])
    pip_minor_version = int(pip.__version__.split('.')[1])
    pip_major_minor = (pip_major_version, pip_minor_version)
    # 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 (9, 0) <= pip_major_minor < (10, 0):
        return 'from pip import main'
    elif (10, 0) <= pip_major_minor < (19, 3):
        # Pip changed their import structure again in 19.3
        # https://github.com/pypa/pip/commit/09fd200
        return 'from pip._internal import main'
    elif (19, 3) <= pip_major_minor < (20, 0):
        return 'from pip._internal.main import main'
    elif (20, 0) <= pip_major_minor < (21, 0):
        # More changes! https://github.com/pypa/pip/issues/7498
        return 'from pip._internal.cli.main import main'
    raise RuntimeError("Unknown import string for pip version: %s"
                       % str(pip_major_minor)) 
Example #2
Source File: __init__.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    import pip._internal
    return pip._internal.main(args) 
Example #3
Source File: setup.py    From video-to-ascii with MIT License 5 votes vote down vote up
def install_package(package):
    import pip
    from pip._internal import main
    main.main(['install', package]) 
Example #4
Source File: __init__.py    From Imogen with MIT License 5 votes vote down vote up
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    import pip._internal
    return pip._internal.main(args) 
Example #5
Source File: __init__.py    From unity-python with MIT License 5 votes vote down vote up
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    import pip._internal
    return pip._internal.main(args) 
Example #6
Source File: __init__.py    From android_universal with MIT License 5 votes vote down vote up
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    import pip._internal
    return pip._internal.main(args)