Lockfile APIο
Warning
This feature is experimental and subject to breaking changes. See the Conan stability section for more information.
Warning
Subapis must not be initialized by themselves. They are intended to be accessed only through the main ConanAPI attributes.
- class LockfileAPI(conan_api)ο
Loads and saves Lockfiles from disk, modifies and manipulates them.
At the moment Lockfile objects are βopaqueβ objects, they are not intended to be used independently, only to be retrieved from this API and passed as arguments to methods of the API.
- static get_lockfile(lockfile=None, conanfile_path=None, cwd=None, partial=False, overrides=None) Lockfileο
obtain a lockfile, following this logic:
If lockfile is explicitly defined, it would be either absolute or relative to cwd and the lockfile file must exist. If lockfile=ββ (empty string) the default βconan.lockβ lockfile will not be automatically used even if it is present.
If lockfile is not defined, it will still look for a default conan.lock:
if conanfile_path is defined, it will be besides it
if conanfile_path is not defined, the default conan.lock should be in cwd
if the default conan.lock cannot be found, it is not an error
- Parameters:
partial β If the obtained lockfile will allow partial resolving
cwd β the current working dir, if None, os.getcwd() will be used
conanfile_path β The full path to the conanfile, if existing
lockfile β the name of the lockfile file
overrides β Dictionary of overrides {overriden: [new_ref1, new_ref2]}
- check_lockfile_config(lockfile: Lockfile)ο
Verify that installed configurations are aligned with lockfile config_requires.
- Parameters:
lockfile β The lockfile to check, can be None
- update_lockfile_export(lockfile, conanfile, ref, is_build_require=False) Lockfileο
Update the lockfile or create a new one with the information resulting from a conan export operation, so the recently exported version and revision can be locked and prioritized.
- Parameters:
lockfile β The lockfile to update. Can be None and a new lockfile will be created
conanfile β The exported conanfile
ref β The reference of the exported conanfile, including its recipe revision
is_build_require β If True, the exported conanfile is for a tool used as tool_requires
- Returns:
The updated lockfile
- static update_lockfile(lockfile, graph, lock_packages=False, clean=False) Lockfileο
Update the lockfile with information from the dependency graph
- Parameters:
lockfile β The lockfile to update. It can be None, and a new lockfile will be created.
graph β The dependency graph
lock_packages β Unused, do not use or define it.
clean β If true, completely clean the lockfile, computing a new lockfile from graph
- static merge_lockfiles(lockfiles) Lockfileο
Merge multiple lockfiles into a single lockfile.
- Parameters:
lockfiles β list of lockfiles to merge
- Returns:
the merged lockfile
- static add_lockfile(lockfile=None, requires=None, build_requires=None, python_requires=None, config_requires=None) Lockfileο
Add requires to a lockfile. If the lockfile doesnβt exist, it will be created
- Parameters:
lockfile β The lockfile to add to. Can be
None.requires β The list of requirements to add. Can be
None.build_requires β The list of build requirements to add. Can be
None.python_requires β The list of Python requirements to add. Can be
None.config_requires β The list of configuration requirements to add. Can be
None.
- Returns:
The lockfile with the added information.
- static remove_lockfile(lockfile: Lockfile, requires=None, build_requires=None, python_requires=None, config_requires=None) Lockfileο
Remove entries from lockfile
- Parameters:
lockfile β The lockfile to remove entries. It will be mutated in place.
requires β The list of requires to remove
build_requires β The list of build requires to remove
python_requires β The list of python_requires to remove
config_requires β The list of config_requires to remove
- Returns:
The modified lockfile
- static save_lockfile(lockfile: Lockfile, lockfile_out, path=None)ο
Save lockfile to disk
- Parameters:
lockfile β The lockfile object to save. If None, nothing will be saved
lockfile_out β The output lockfile filename
path β The path of the output lockfile, if None, it will be cwd