Utilities for the building of packages and logging thereof.
Index
|
Download and unpack the archive from the provided URL. |
|
Run the |
|
Write the |
|
Build and install a package via GNU make. |
|
Check that a PEP 440-compliant version is provided. |
|
A re-usable, non-reentrant and non-thread-safe context decorator for logging github-style |
|
A |
The |
|
The |
|
The |
API
- dep_builder.download_and_unpack(url: str, archive_path: str | PathLike[str] = 'tmp.tar.gz', delete_archive: bool = True) Path [source]
Download and unpack the archive from the provided URL.
- Parameters:
url (str) – The URL to the to-be downloaded tar archive.
archive_path (str | os.PathLike[str]) – The (absolute) path to the to-be downloaded archive.
delete_archive (bool) – Whether the archive should be deleted after the download is complete.
- Returns:
The absolute path to the downloaded and extracted archive.
- Return type:
- dep_builder.configure(src_path: str | PathLike[str], build_path: str | PathLike[str] = 'build', config_args: Iterable[str] = ()) None [source]
Run the
configure
executable from the passed source path.- Parameters:
src_path (str | os.PathLike[str]) – The path to the source directory.
build_path (str | os.PathLike[str]) – The path to the to-be created build directory.
config_args (Iterable[str]) – Arguments for the
configure
executable insrc_path
.
- dep_builder.read_config_log(build_path: str | PathLike[str] = 'build', log_name: str | PathLike[str] = 'config.log') None [source]
Write the
./configure
output to the logger.- Parameters:
build_path (str | os.PathLike[str]) – The path to the build directory.
log_name (str | os.PathLike[str]) – The name of the logfile inside
build_path
.
- dep_builder.build(build_path: str | PathLike[str], cpu_count: int | None = None) None [source]
Build and install a package via GNU make.
- Parameters:
build_path (str | os.PathLike[str]) – The path to the build directory.
cpu_count (int | None) – The number of CPU cores to use for the build process. Using
None
defaults to the output ofos.cpu_count()
.
- dep_builder.parse_version(version: str) Version [source]
Check that a PEP 440-compliant version is provided.
- Parameters:
version (str) – The to-be validated version.
- Returns:
The fully parsed version object.
- Return type:
- class dep_builder.BaseTimeLogger(logger: logging.Logger, message: None | str = None)[source]
A re-usable, non-reentrant and non-thread-safe context decorator for logging github-style
:group:
blocks before/after function calls.Examples
>>> import sys >>> import logging >>> from dep_builder import BaseTimeLogger >>> logger = logging.getLogger() >>> logger.setLevel(logging.INFO) >>> logger.addHandler(logging.StreamHandler(stream=sys.stdout)) >>> @BaseTimeLogger(logger, "message block") ... def func() -> None: ... print("1 2 3 4") >>> func() ::group::message block 1 2 3 4 ::endgroup:: ✓ 0.00s
- Parameters:
logger (logging.Logger) – The to-be wrapped
Logger
.message (None | str) – The group-message to-be displayed upon entering the context manager.
- property logger: logging.Logger
The wrapped
Logger
.
- class dep_builder.TimeLogger(message: None | str = None)[source]
A
BaseTimeLogger
subclass with a fixedLogger
instance.Examples
>>> from dep_builder import TimeLogger >>> @TimeLogger("message block") ... def func() -> None: ... print("1 2 3 4") >>> func() ::group::message block 1 2 3 4 ::endgroup:: ✓ 0.00s
- Parameters:
message (None | str) – The group-message to-be displayed upon entering the context manager.
See also
dep_builder.logger
The
dep_builder
logger as used by this class.
- dep_builder.logger: logging.Logger = <Logger dep_builder (DEBUG)>
The
dep_builder
logger.
- dep_builder.__version__: str = '3.2.0'
The
dep_builder
version.