Skip to content

Plugin utilities


hatchling.builders.utils.get_reproducible_timestamp()

Returns an int derived from the SOURCE_DATE_EPOCH environment variable; see https://reproducible-builds.org/specs/source-date-epoch/.

The default value will always be: 1580601600

Source code in hatchling/builders/utils.py
def get_reproducible_timestamp():
    """
    Returns an `int` derived from the `SOURCE_DATE_EPOCH` environment variable; see
    https://reproducible-builds.org/specs/source-date-epoch/.

    The default value will always be: `1580601600`
    """
    return int(os.environ.get('SOURCE_DATE_EPOCH', '1580601600'))

BuilderConfig

dependencies property readonly

dev_mode_dirs property readonly

Directories which must be added to Python's search path in dev mode.

directory property readonly

ignore_vcs property readonly

reproducible property readonly

Whether or not the target should be built in a reproducible manner, defaulting to true.

versions property readonly

default_exclude(self)

default_include(self)

default_packages(self)

Application

The way output is displayed can be configured by users.

abort(self, message = '', code = 1, **kwargs)

Terminate the program with the given return code.

display_debug(self, message = '', level = 1, **kwargs)

Meant to be used for messages that are not useful for most user experiences. The level option must be between 1 and 3 (inclusive).

display_error(self, message = '', **kwargs)

Meant to be used for messages indicating some unrecoverable error.

display_info(self, message = '', **kwargs)

Meant to be used for messages conveying basic information.

display_success(self, message = '', **kwargs)

Meant to be used for messages indicating some positive outcome.

display_waiting(self, message = '', **kwargs)

Meant to be used for messages shown before potentially time consuming operations.

display_warning(self, message = '', **kwargs)

Meant to be used for messages conveying important information.

Platform

default_shell property readonly

Returns the default shell of the system.

On Windows systems first try the SHELL environment variable, if present, followed by the COMSPEC environment variable, defaulting to cmd. On all other platforms only the SHELL environment variable will be used, defaulting to bash.

linux property readonly

Indicates whether Hatch is running on neither Windows nor macOS.

macos property readonly

Indicates whether Hatch is running on macOS.

modules property readonly

Accessor for lazily loading modules that either take multiple milliseconds to import (like shutil and subprocess) or are not used on all platforms (like shlex).

name property readonly

One of the following:

  • linux
  • windows
  • macos

windows property readonly

Indicates whether Hatch is running on Windows.

capture_process(self, command: str | list[str], shell = False, **kwargs)

Equivalent to the standard library's subprocess.Popen, with all output captured by stdout and the command first being properly formatted.

check_command(self, command: str | list[str], shell = False, **kwargs)

Equivalent to run_command, but non-zero exit codes will gracefully end program execution.

check_command_output(self, command: str | list[str], shell = False, **kwargs) -> str

Equivalent to the output from the process returned by capture_process, but non-zero exit codes will gracefully end program execution.

exit_with_command(self, command: list[str])

Run the given command and exit with its exit code. On non-Windows systems, this uses the standard library's os.execvp.

format_for_subprocess(self, command: str | list[str], *, shell: bool)

Format the given command in a cross-platform manner for immediate consumption by subprocess utilities.

run_command(self, command: str | list[str], shell = False, **kwargs)

Equivalent to the standard library's subprocess.run, with the command first being properly formatted.

EnvironmentContextFormatter (EnvironmentContextFormatterBase)

formatters(self)

This returns a mapping of supported field names to their respective formatting functions. Each function accepts 2 arguments:

  • the value that was passed to the format call, defaulting to None
  • the modifier data, defaulting to an empty string

Last update: May 22, 2022