pip_shims.models module

Helper module for shimming functionality across pip versions.

class pip_shims.models.ImportTypes[source]

Bases: pip_shims.models.ImportTypes

Create new instance of ImportTypes(FUNCTION, CLASS, MODULE, CONTEXTMANAGER)

ATTRIBUTE = 5
CLASS = 1
CONTEXTMANAGER = 3
FUNCTION = 0
METHOD = 4
MODULE = 2
_asdict()

Return a new OrderedDict which maps field names to their values.

_fields = ('FUNCTION', 'CLASS', 'MODULE', 'CONTEXTMANAGER')
_fields_defaults = {}
classmethod _make(iterable)

Make a new ImportTypes object from a sequence or iterable

_replace(**kwds)

Return a new ImportTypes object replacing specified fields with new values

count()

Return number of occurrences of value.

index()

Return first index of value.

Raises ValueError if the value is not present.

pip_shims.models.ImportTypesBase

alias of pip_shims.models.ImportTypes

class pip_shims.models.PipVersion(version, round_prereleases_up=True, base_import_path=None, vendor_import_path='pip._vendor')[source]

Bases: collections.abc.Sequence

_abc_impl = <_abc_data object>
_parse()[source]
count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

is_valid(compared_to)[source]
version_key
version_tuple
class pip_shims.models.PipVersionRange(start, end)[source]

Bases: collections.abc.Sequence

_abc_impl = <_abc_data object>
base_import_paths
count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

is_valid()[source]
vendor_import_paths
class pip_shims.models.ShimmedPath(name, import_target, import_type, version_range, provided_methods=None, provided_functions=None, provided_classmethods=None, provided_contextmanagers=None, provided_mixins=None, default_args=None)[source]

Bases: object

_ShimmedPath__modules = {'pip._internal.cache': <module 'pip._internal.cache' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cache.py'>, 'pip._internal.cli': <module 'pip._internal.cli' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cli/__init__.py'>, 'pip._internal.cli.base_command': <module 'pip._internal.cli.base_command' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cli/base_command.py'>, 'pip._internal.cli.cmdoptions': <module 'pip._internal.cli.cmdoptions' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py'>, 'pip._internal.cli.parser': <module 'pip._internal.cli.parser' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cli/parser.py'>, 'pip._internal.cli.req_command': <module 'pip._internal.cli.req_command' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/cli/req_command.py'>, 'pip._internal.commands': <module 'pip._internal.commands' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/commands/__init__.py'>, 'pip._internal.commands.freeze': <module 'pip._internal.commands.freeze' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/commands/freeze.py'>, 'pip._internal.commands.install': <module 'pip._internal.commands.install' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/commands/install.py'>, 'pip._internal.distributions': <module 'pip._internal.distributions' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py'>, 'pip._internal.distributions.base': <module 'pip._internal.distributions.base' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/distributions/base.py'>, 'pip._internal.distributions.installed': <module 'pip._internal.distributions.installed' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/distributions/installed.py'>, 'pip._internal.distributions.sdist': <module 'pip._internal.distributions.sdist' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/distributions/sdist.py'>, 'pip._internal.distributions.wheel': <module 'pip._internal.distributions.wheel' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/distributions/wheel.py'>, 'pip._internal.exceptions': <module 'pip._internal.exceptions' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/exceptions.py'>, 'pip._internal.index.collector': <module 'pip._internal.index.collector' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/index/collector.py'>, 'pip._internal.index.package_finder': <module 'pip._internal.index.package_finder' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/index/package_finder.py'>, 'pip._internal.locations': <module 'pip._internal.locations' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/locations.py'>, 'pip._internal.models.format_control': <module 'pip._internal.models.format_control' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/format_control.py'>, 'pip._internal.models.index': <module 'pip._internal.models.index' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/index.py'>, 'pip._internal.models.link': <module 'pip._internal.models.link' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/link.py'>, 'pip._internal.models.search_scope': <module 'pip._internal.models.search_scope' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/search_scope.py'>, 'pip._internal.models.selection_prefs': <module 'pip._internal.models.selection_prefs' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/selection_prefs.py'>, 'pip._internal.models.target_python': <module 'pip._internal.models.target_python' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/models/target_python.py'>, 'pip._internal.network.cache': <module 'pip._internal.network.cache' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/network/cache.py'>, 'pip._internal.network.download': <module 'pip._internal.network.download' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/network/download.py'>, 'pip._internal.operations.freeze': <module 'pip._internal.operations.freeze' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/operations/freeze.py'>, 'pip._internal.operations.prepare': <module 'pip._internal.operations.prepare' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/operations/prepare.py'>, 'pip._internal.req.constructors': <module 'pip._internal.req.constructors' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/constructors.py'>, 'pip._internal.req.req_file': <module 'pip._internal.req.req_file' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/req_file.py'>, 'pip._internal.req.req_install': <module 'pip._internal.req.req_install' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/req_install.py'>, 'pip._internal.req.req_set': <module 'pip._internal.req.req_set' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/req_set.py'>, 'pip._internal.req.req_tracker': <module 'pip._internal.req.req_tracker' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/req_tracker.py'>, 'pip._internal.req.req_uninstall': <module 'pip._internal.req.req_uninstall' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/req/req_uninstall.py'>, 'pip._internal.resolution.legacy.resolver': <module 'pip._internal.resolution.legacy.resolver' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py'>, 'pip._internal.utils.compat': <module 'pip._internal.utils.compat' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/utils/compat.py'>, 'pip._internal.utils.hashes': <module 'pip._internal.utils.hashes' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/utils/hashes.py'>, 'pip._internal.utils.misc': <module 'pip._internal.utils.misc' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/utils/misc.py'>, 'pip._internal.utils.temp_dir': <module 'pip._internal.utils.temp_dir' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/utils/temp_dir.py'>, 'pip._internal.utils.urls': <module 'pip._internal.utils.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/utils/urls.py'>, 'pip._internal.vcs.versioncontrol': <module 'pip._internal.vcs.versioncontrol' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py'>, 'pip._internal.wheel_builder': <module 'pip._internal.wheel_builder' from '/home/docs/checkouts/readthedocs.org/user_builds/pip-shims/envs/stable/lib/python3.7/site-packages/pip/_internal/wheel_builder.py'>}
_apply_aliases(imported, target)[source]
_as_tuple()[source]
_ensure_functions(provided)[source]
_ensure_methods(provided)[source]

Given a base class, a new name, and any number of functions to attach, turns those functions into classmethods, attaches them, and returns an updated class object.

_import(prefix=None)[source]
classmethod _import_module(module)[source]
classmethod _parse_provides_dict(provides, prepend_arg_to_callables=None)[source]
_shim_base(imported, attribute_name)[source]
_shim_parent(imported, attribute_name)[source]
_update_default_kwargs(parent, provided)[source]
alias(aliases)[source]
calculated_module_path
is_attribute
is_class
is_contextmanager
is_function
is_method
is_module
is_valid
shim()[source]
shim_attribute(imported, attribute_name)[source]
shim_class(imported, attribute_name)[source]
shim_contextmanager(imported, attribute_name)[source]
shim_function(imported, attribute_name)[source]
shim_module(imported, attribute_name)[source]
shimmed
sort_order
update_sys_modules(imported)[source]
class pip_shims.models.ShimmedPathCollection(name, import_type, paths=None)[source]

Bases: object

_ShimmedPathCollection__registry = {'AbstractDistribution': <pip_shims.models.ShimmedPathCollection object>, 'BadCommand': <pip_shims.models.ShimmedPathCollection object>, 'BestVersionAlreadyInstalled': <pip_shims.models.ShimmedPathCollection object>, 'CandidateEvaluator': <pip_shims.models.ShimmedPathCollection object>, 'CandidatePreferences': <pip_shims.models.ShimmedPathCollection object>, 'Command': <pip_shims.models.ShimmedPathCollection object>, 'CommandError': <pip_shims.models.ShimmedPathCollection object>, 'ConfigOptionParser': <pip_shims.models.ShimmedPathCollection object>, 'DEV_PKGS': <pip_shims.models.ShimmedPathCollection object>, 'DistributionNotFound': <pip_shims.models.ShimmedPathCollection object>, 'Downloader': <pip_shims.models.ShimmedPathCollection object>, 'FAVORITE_HASH': <pip_shims.models.ShimmedPathCollection object>, 'FormatControl': <pip_shims.models.ShimmedPathCollection object>, 'FrozenRequirement': <pip_shims.models.ShimmedPathCollection object>, 'InstallCommand': <pip_shims.models.ShimmedPathCollection object>, 'InstallRequirement': <pip_shims.models.ShimmedPathCollection object>, 'InstallationError': <pip_shims.models.ShimmedPathCollection object>, 'InstalledDistribution': <pip_shims.models.ShimmedPathCollection object>, 'Link': <pip_shims.models.ShimmedPathCollection object>, 'LinkCollector': <pip_shims.models.ShimmedPathCollection object>, 'LinkEvaluator': <pip_shims.models.ShimmedPathCollection object>, 'PackageFinder': <pip_shims.models.ShimmedPathCollection object>, 'PipError': <pip_shims.models.ShimmedPathCollection object>, 'PreviousBuildDirError': <pip_shims.models.ShimmedPathCollection object>, 'PyPI': <pip_shims.models.ShimmedPathCollection object>, 'RequirementPreparer': <pip_shims.models.ShimmedPathCollection object>, 'RequirementSet': <pip_shims.models.ShimmedPathCollection object>, 'RequirementTracker': <pip_shims.models.ShimmedPathCollection object>, 'RequirementsFileParseError': <pip_shims.models.ShimmedPathCollection object>, 'Resolver': <pip_shims.models.ShimmedPathCollection object>, 'SafeFileCache': <pip_shims.models.ShimmedPathCollection object>, 'SearchScope': <pip_shims.models.ShimmedPathCollection object>, 'SelectionPreferences': <pip_shims.models.ShimmedPathCollection object>, 'SessionCommandMixin': <pip_shims.models.ShimmedPathCollection object>, 'SourceDistribution': <pip_shims.models.ShimmedPathCollection object>, 'TargetPython': <pip_shims.models.ShimmedPathCollection object>, 'TempDirectory': <pip_shims.models.ShimmedPathCollection object>, 'USER_CACHE_DIR': <pip_shims.models.ShimmedPathCollection object>, 'UninstallPathSet': <pip_shims.models.ShimmedPathCollection object>, 'UninstallationError': <pip_shims.models.ShimmedPathCollection object>, 'VcsSupport': <pip_shims.models.ShimmedPathCollection object>, 'Wheel': <pip_shims.models.ShimmedPathCollection object>, 'WheelBuilder': <pip_shims.models.ShimmedPathCollection object>, 'WheelCache': <pip_shims.models.ShimmedPathCollection object>, 'WheelDistribution': <pip_shims.models.ShimmedPathCollection object>, '_strip_extras': <pip_shims.models.ShimmedPathCollection object>, 'build': <pip_shims.models.ShimmedPathCollection object>, 'build_one': <pip_shims.models.ShimmedPathCollection object>, 'build_one_inside_env': <pip_shims.models.ShimmedPathCollection object>, 'build_wheel': <pip_shims.models.ShimmedPathCollection object>, 'cmdoptions': <pip_shims.models.ShimmedPathCollection object>, 'commands_dict': <pip_shims.models.ShimmedPathCollection object>, 'get_installed_distributions': <pip_shims.models.ShimmedPathCollection object>, 'get_package_finder': <pip_shims.models.ShimmedPathCollection object>, 'get_requirement_set': <pip_shims.models.ShimmedPathCollection object>, 'get_requirement_tracker': <pip_shims.models.ShimmedPathCollection object>, 'get_resolver': <pip_shims.models.ShimmedPathCollection object>, 'get_supported': <pip_shims.models.ShimmedPathCollection object>, 'get_tags': <pip_shims.models.ShimmedPathCollection object>, 'global_tempdir_manager': <pip_shims.models.ShimmedPathCollection object>, 'index_group': <pip_shims.models.ShimmedPathCollection object>, 'install_req_from_editable': <pip_shims.models.ShimmedPathCollection object>, 'install_req_from_line': <pip_shims.models.ShimmedPathCollection object>, 'install_req_from_req_string': <pip_shims.models.ShimmedPathCollection object>, 'is_archive_file': <pip_shims.models.ShimmedPathCollection object>, 'is_file_url': <pip_shims.models.ShimmedPathCollection object>, 'is_installable_dir': <pip_shims.models.ShimmedPathCollection object>, 'make_abstract_dist': <pip_shims.models.ShimmedPathCollection object>, 'make_distribution_for_install_requirement': <pip_shims.models.ShimmedPathCollection object>, 'make_option_group': <pip_shims.models.ShimmedPathCollection object>, 'make_preparer': <pip_shims.models.ShimmedPathCollection object>, 'parse_requirements': <pip_shims.models.ShimmedPathCollection object>, 'path_to_url': <pip_shims.models.ShimmedPathCollection object>, 'resolve': <pip_shims.models.ShimmedPathCollection object>, 'shim_unpack': <pip_shims.models.ShimmedPathCollection object>, 'stdlib_pkgs': <pip_shims.models.ShimmedPathCollection object>, 'unpack_url': <pip_shims.models.ShimmedPathCollection object>, 'url_to_path': <pip_shims.models.ShimmedPathCollection object>, 'wheel_cache': <pip_shims.models.ShimmedPathCollection object>}
_get_top_path()[source]
_sort_paths()[source]
add_mixin(mixin)[source]
add_path(path)[source]
alias(aliases)[source]

Takes a list of methods, functions, attributes, etc and ensures they all exist on the object pointing at the same referent.

Parameters:aliases (List[str]) – Names to map to the same functionality if they do not exist.
Returns:None
Return type:None
create_path(import_path, version_start, version_end=None)[source]
classmethod get_registry()[source]
pre_shim(fn)[source]
provide_function(name, fn)[source]
provide_method(name, fn)[source]
register()[source]
set_default(default)[source]
set_default_args(callable_name, *args, **kwargs)[source]
shim()[source]
classmethod traverse(shim)[source]
pip_shims.models.import_pip()[source]
pip_shims.models.lookup_current_pip_version()[source]
pip_shims.models.pip_version_lookup(version, *args, **kwargs)[source]