requirementslib.models.cache module

exception requirementslib.models.cache.CorruptCacheError(path)[source]

Bases: Exception

class requirementslib.models.cache.DependencyCache(cache_dir=None)[source]

Bases: object

Creates a new persistent dependency cache for the current Python version. The cache file is written to the appropriate user cache dir for the current platform, i.e.

~/.cache/pip-tools/depcache-pyX.Y.json

Where X.Y indicates the Python version.

as_cache_key(ireq)[source]

Given a requirement, return its cache key. This behavior is a little weird in order to allow backwards compatibility with cache files. For a requirement without extras, this will return, for example:

(“ipython”, “2.1.0”)

For a requirement with extras, the extras will be comma-separated and appended to the version, inside brackets, like so:

(“ipython”, “2.1.0[nbconvert,notebook]”)

cache

The dictionary that is the actual in-memory cache. This property lazily loads the cache from disk.

clear()[source]
get(ireq, default=None)[source]
read_cache()[source]

Reads the cached contents into memory.

reverse_dependencies(ireqs)[source]

Returns a lookup table of reverse dependencies for all the given ireqs.

Since this is all static, it only works if the dependency cache contains the complete data, otherwise you end up with a partial view. This is typically no problem if you use this function after the entire dependency tree is resolved.

write_cache()[source]

Writes the cache to disk as JSON.

class requirementslib.models.cache.HashCache(*args, **kwargs)[source]

Bases: pip._internal.network.cache.SafeFileCache

Caches hashes of PyPI artifacts so we do not need to re-download them.

Hashes are only cached when the URL appears to contain a hash in it and the cache key includes the hash value returned from the server). This ought to avoid ssues where the location on the server changes.

get_hash(location)[source]
class requirementslib.models.cache.RequiresPythonCache(cache_dir='/home/docs/.cache/pipenv')[source]

Bases: requirementslib.models.cache._JSONCache

Cache a candidate’s Requires-Python information.

filename_format = 'pyreqcache-py{python_version}.json'
requirementslib.models.cache.read_cache_file(cache_file_path)[source]