Lock collections¶
Load .in and .lock files once.
.in files are never changed.
.lock files are changed. So if cached, after writes, the cache
would have to be invalidated
- wreck.lock_collections._logger: logging.Logger¶
Module level logger
- class wreck.lock_collections.Ins(loader: VenvMapLoader, venv_path: dataclasses.InitVar[str])¶
Store the
.inFilePins.Benefits
FilePins.by_pkg get (PinDatum) by package name returns a list, rather than one More complex pins can be represented
colorama<=1.5.0; python_version<="3.8" colorama>1.5.0, <=1.8.0; python_version>"3.8"; python_version<"3.10" colorama>1.8.0; python_version>="3.10"
- Variables:
venv_path (Any) – Relative path to venv base folder. Acts as a key
- loader: wreck.pep518_venvs.VenvMapLoader¶
Contains some paths and loaded not parsed venv reqs
- _file_pins: list[wreck.lock_filepins.FilePins]¶
Collection of PinDatum
- _iter: collections.abc.Iterator[wreck.lock_filepins.FilePins]¶
Automatically reusable Iterator
- _files: set[wreck.lock_filepins.FilePins]¶
Set of FilePins. Which contains the relative path to a Requirement file. May contain unresolved constraints
- _zeroes: set[wreck.lock_filepins.FilePins]¶
Set of FilePins that have all constraints resolved
- Raises:
TypeError– Unsupported type for loaderwreck.exceptions.MissingPackageBaseFolder– loader did not provide package base folder
- property files¶
Generator of sorted FilePins
- Returns:
Yields InFile. These tend to contain constraints
- Return type:
collections.abc.Generator[wreck.lock_filepins.FilePins, None, None]
- property files_len¶
Item count within unresolved files set, files
- Returns:
files count
- Return type:
- get_by_abspath(abspath_f, set_name=InFileType.FILES)¶
Get the index and
FilePins- Parameters:
abspath_f¶ (pathlib.Path) – relative path of an
.infileset_name¶ (str | None) – Default
wreck.lock_datum.InFileType.FILES. Which set to search thru. zeroes or files.
- Returns:
The
.infile and index withinFilePins- Return type:
wreck.lock_filepins.FilePins | None
- Raises:
ValueError– Unsupported type. relpath is neither str nor Path
- in_files(val)¶
Check if within InFiles
- in_zeroes(val)¶
Check if within zeroes
- load(suffix_last='.in')¶
Load
.infiles- Parameters:
suffix_last¶ (str | None) – Default .in process in file last suffix
- Raises:
wreck.exceptions.MissingRequirementsFoldersFiles– missing requirements file(s). Create it
- move_zeroes()¶
Zeroes have had all their constraints resolved and therefore do not need to be further scrutinized.
- property path_cwd¶
package base folder. During testing this will be tmp_path, not the source package folder
- Returns:
package base folder. None is anything else besides a loader
- Return type:
- resolution_loop()¶
Run loop of resolve_zeroes calls, sampling before and after counts. If not fully resolved and two iterations have the same result, raise an Exception
- Raises:
wreck.exceptions.MissingRequirementsFoldersFiles– there are unresolvable constraint(s)
- resolve_zeroes()¶
A requirements (
.in) file may contain constraints (-c), and/or requirements (-r). If possible resolve by a zero (a completely resolved file)._files and _zeroes are both type, set. When resolved, the FilePins instance is moved from _file –> _zeroes
Constraints vs requirements. What’s the difference?
constraint – subset of requirements features. Intended to restrict package versions. Does not necessarily (might not) install the package
Does not support:
editable mode (-e)
extras (e.g. coverage[toml])
wreck convention
Requirements files for the purpose as constraints, file name is prefixed with
pins-*[.shared].in.These files do not need to be compiled/rendered into
.lock/.unlockrespectively..sharedmeans shared across multiple venvs.
- venv_path: dataclasses.InitVar[str]¶
- write()¶
After resolving all constraints. Write out all .unlock files
- Returns:
Generator of
.unlockabsolute paths- Return type:
collections.abc.Generator[pathlib.Path, None, None]
reqs unlock --path=[test folder] --venv-relpath='.venv'
- property zeroes¶
Generator of FilePins
- Returns:
Yields FilePins without any constraints
- Return type:
collections.abc.Generator[wreck.lock_filepins.FilePins, None, None]
- wreck.lock_collections.unlock_compile(loader, venv_relpath)¶
Create .unlock files
- Parameters:
loader¶ (wreck.pep518_venvs.VenvMapLoader) – Contains some paths and loaded unparsed mappings
venv_relpath¶ (Any | None) – venv relative path is a key. To choose a tools.venvs.req
- Returns:
Generator of abs path to .unlock files
- Return type:
collections.abc.Generator[pathlib.Path, None, None]