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.__all__: tuple[str, str] = ("Ins", "unlock_compile")

Module exports

wreck.lock_collections.is_module_debug: bool = False

Toggle on/off module level logging

wreck.lock_collections._logger: logging.Logger

Module level logger

class wreck.lock_collections.Ins(loader: VenvMapLoader, venv_path: dataclasses.InitVar[str])

Store the .in FilePins.

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

_venv_relpath: str

Relative path to venv base folder. Acts as a key

_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:
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:

int

get_by_abspath(abspath_f, set_name=InFileType.FILES)

Get the index and FilePins

Parameters:
Returns:

The .in file and index within FilePins

Return type:

wreck.lock_filepins.FilePins | None

Raises:
  • ValueError – Unsupported type. relpath is neither str nor Path

in_files(val)

Check if within InFiles

Parameters:

val (Any) – item to check if within InFiles

Returns:

True if InFile contained within InFiles otherwise False

Return type:

bool

in_zeroes(val)

Check if within zeroes

Parameters:

val (Any) – item to check if within zeroes

Returns:

True if InFile contained within zeroes otherwise False

Return type:

bool

load(suffix_last='.in')

Load .in files

Parameters:

suffix_last (str | None) – Default .in process in file last suffix

Raises:
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:

pathlib.Path

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:
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/.unlock respectively.

.shared means shared across multiple venvs.

venv_path: dataclasses.InitVar[str]
write()

After resolving all constraints. Write out all .unlock files

Returns:

Generator of .unlock absolute 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]

property zeroes_len

Item count within resolved files set, zeroes

Returns:

zeroes count

Return type:

int

wreck.lock_collections.unlock_compile(loader, venv_relpath)

Create .unlock files

Parameters:
Returns:

Generator of abs path to .unlock files

Return type:

collections.abc.Generator[pathlib.Path, None, None]