Utilities for the building of packages and logging thereof.

Index

download_and_unpack(url[, archive_path, ...])

Download and unpack the archive from the provided URL.

configure(src_path[, build_path, config_args])

Run the configure executable from the passed source path.

read_config_log([build_path, log_name])

Write the ./configure output to the logger.

build(build_path[, cpu_count])

Build and install a package via GNU make.

parse_version(version)

Check that a PEP 440-compliant version is provided.

BaseTimeLogger(logger[, message])

A re-usable, non-reentrant and non-thread-safe context decorator for logging github-style :group: blocks before/after function calls.

TimeLogger([message])

A BaseTimeLogger subclass with a fixed Logger instance.

logger

The dep_builder logger.

__version__

The dep_builder version.

__version_tuple__

The dep_builder version as a tuple.

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:

pathlib.Path

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 in src_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:
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 of os.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:

packaging.version.Version

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.

flush() None[source]

Flush all logging handlers.

property logger: logging.Logger

The wrapped Logger.

property message: None | str

The group-message to-be displayed upon entering the context manager.

write(message: str) None[source]

Write to the logger at the INFO level.

class dep_builder.TimeLogger(message: None | str = None)[source]

A BaseTimeLogger subclass with a fixed Logger 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.

dep_builder.__version_tuple__: tuple[int, int, int, str, str] = (3, 2, 0)

The dep_builder version as a tuple.