Use built-in build rules in Please
masterbuiltins.build_defs, which contains functions known to the Please interpreter that may have custom, optimized implementations.repository·master·Indexed 25 days ago
https://github.com/thought-machine/pleaseA high-performance, cross-language build system designed for extensibility and reproducibility. Please uses a hermetic caching model based on input hashes to enable fast, parallel builds. It features a hybrid build language (ASP), a consistent CLI via the `plz` command, and support for remote execution via the remote execution API and HTTP caching.
builtins.build_defs, which contains functions known to the Please interpreter that may have custom, optimized implementations.http_cache tool implements a lightweight, resource-based HTTP server that please can use as a cache. It allows please to store files via PUT requests and retrieve them via GET requests. While any HTTP server (like nginx) can be used, http_cache is designed to be easy to configure for this specific purpose.The Please Alpine image provides a minimal, canonical build environment for building Please and its associated tools in Linux. It is the environment used to release official binaries.
Note: This image is optimized for building and is fairly minimal. It does not contain all the dependencies required to run all language-specific tests. If you need to run the full suite of language-specific tests, use the Ubuntu image instead.
The Please build system is built around several central structures that manage the build lifecycle, graph, and configuration:
BuildTarget: Represents a specific task for the build system (created via build_rule(), filegroup(), or remote_file()).BuildLabel: The unique identifier used to refer to build targets (e.g., //third_party/go:testify).BuildGraph: A collection of all parsed build targets and subrepos.Configuration: The combined configuration derived from .plzconfig files.BuildState: Manages the current build state, including the build graph, configuration, and progress. It tracks whether the system should queue targets for testing or parsing. BuildState is cloned for subrepos, though parts like the build graph are shared.Subrepo: A subrepo added to the build graph, created via subrepo() calls, specific architectures (e.g., ///linux_amd64//...), or the --arch command-line flag.ASP is a custom parser for BUILD files that uses a syntactically restricted subset of Python. When writing BUILD files using ASP, be aware of the following language constraints:
The following keywords are unavailable and cannot be used as identifiers:
import, try, except, finally, class, global, nonlocal, while, asyncbool, int, str, list, dict, and functions.float, complex, set, frozenset, bytes.+, <, >, %, and, or, in, not in, is, is not, ==, >=, <=, !=.= and the augmented assignment operator += are supported. Other augmented assignments (like -=) are not available.for clauses), but generator expressions are not.% and f-strings. Note that .format() is available but has an incomplete implementation and its use is discouraged.assert statement is supported, but errors cannot be caught because try/except are unavailable.| operator (e.g., foo:list|dict=[]).[] or {}.append and extend may work, they do not always follow standard Python semantics (e.g., they might not modify the original object if it originated from a surrounding scope).Best Practice: Instead of using append or extend, use the += augmented assignment operator to modify lists.
The parse package is responsible for parsing and interpreting BUILD files to populate the build graph. It uses the asp dialect (a Python dialect) for interpretation.
The parsing lifecycle follows these steps:
state.SyncParsePackage(label).nil, you are the first to parse this package and must proceed to parse it.state.SyncParsePackage(label).The alternative Ubuntu image is a modified version of the standard Ubuntu image used specifically for testing compatibility in environments with different OS and package versions.
Warning: This image is not recommended for normal production or development use.
Notable differences from the standard image:
The remote package provides a client for building please targets using the remote execution API.
When building with remote execution, the client follows this workflow:
srcs). Note that dependencies (deps) should already exist in the Content Addressable Storage (CAS) from previous builds.Important Notes:
The k8s plugin allows you to create Kubernetes manifests that are automatically templated with the correct image tags from your docker_image rules.
1. Install the plugin:
plz init plugin k8s2. Define k8s_config in a BUILD file:
k8s_config(
name = "k8s",
srcs = [
"deployment.yaml",
"service.yaml",
],
containers = [":image"],
)3. Build and deploy:
Building the k8s_config target generates templated YAML files in plz-out/gen/. The plugin also provides a _push target to apply these manifests to your cluster via kubectl:
plz build //hello_service/k8s:k8s
plz run //hello_service/k8s:k8s_pushTo build Docker images, first install the docker and shell plugins:
plz init plugin shell && plz init plugin dockerUse the docker_image rule in a BUILD file to define your image. Building the rule generates a shell script that performs the actual docker build command.
Example docker_image rule:
docker_image(
name = "image",
srcs = ["//hello_service"],
dockerfile = "Dockerfile",
base_image = "//common/docker:base",
)To build and run the image build script:
plz build //hello_service/k8s:image
plz run //hello_service/k8s:image.shThe Please Ubuntu image provides a canonical supported environment containing all dependencies required to build Please, run associated tools, and execute all tests.
Supported environments: