kraken.std.dist
kraken.std.dist
Create distributions (archives) from build artifacts and resources.
ArchiveWriter
Bases: ABC
Base class to write an archive file.
Source code in kraken/std/dist.py
add_file
abstractmethod
add_path
Recursively add the contents of all files under path.
Source code in kraken/std/dist.py
DistributionTask
Bases: Task
Create an archive from a set of files and resources.
Source code in kraken/std/dist.py
add_to_archive
add_to_archive(
writer: ArchiveWriter,
arcname: str,
path: Path,
test_path: Path | None = None,
exclude: Sequence[str] = (),
include: Sequence[str] | None = None,
) -> None
Recursively adds path to the archive writer under consideration of the exclude and include glob patterns that are tested against test_path.
The glob patterns for the exclude and include arguments are tested against the full relative test_path as well as the individual filename. (NOTE(niklas.rosenstein): To support full .gitignore like behaviour, we'd need to test the entire range from name to full path).
:param writer: The archive writer implementation. :param arcname: The name to give path. Sub-paths are appended to this name as normal. :param path: The path to write to the archive. :param test_path: The path to test the exclude/include patterns against. Sub-paths are appended to this as normal. Defaults to path. :param exclude: A sequence of glob patterns that, if matching, cause an element (file or directory) to be excluded. :param include: If specified, must be a sequence of glob patterns that will cause a file or directory to only be added if any pattern matches, and no exclude pattern matches.
Source code in kraken/std/dist.py
dist
dist(
*,
name: str,
dependencies: (
Sequence[str | Address | Task]
| Mapping[
str | Address,
Mapping[str, Any] | IndividualDistOptions,
]
),
output_file: str | Path,
archive_type: str | None = None,
prefix: str | None = None,
project: Project | None = None
) -> DistributionTask
Create a task that produces a distribution from the resources provided by the tasks specified with include.
:param name: The name of the task.
:param dependencies: A list of tasks or task selectors (resolved relative to the project) that provide the
resources that should be included in the generated archive. If a dictionary is specified, instead, it must
map each dependency to a dictionary of settings that can be deserialized into :class:IndividualDistOptions
.
:param output_file: The output filename to write to. If a string is specified, it will be treated relative to the
project build directory. If a path object is specified, it will be treated relative to the project directory.
:param archive_type: The type of archive to create (e.g. zip
, tar
, tar.gz
, tar.bz2
or tar.xz
). If left
empty, the archive type is derived from the output_filename suffix.
:param project: The project to create the task for.
Source code in kraken/std/dist.py
wopen_archive
wopen_archive(path: Path, type_: str) -> ArchiveWriter
Open an archive at path for writing. The type_ indicates what type of archive will be created.
Accepted values for type_ are zip
, tar
, tar.gz
, tar.bz2
and tar.xz
.