/ prelude / toolchains / python.bzl
python.bzl
 1  # prelude/toolchains/python.bzl
 2  #
 3  # System Python bootstrap toolchain.
 4  #
 5  # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 6  # PRELUDE ARCHAEOLOGY
 7  # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 8  #
 9  # The upstream python.bzl has both:
10  #   - system_python_bootstrap_toolchain (minimal, for prelude scripts)
11  #   - system_python_toolchain (full, with pex support, etc.)
12  #
13  # We only need the bootstrap version. The full Python toolchain pulls in
14  # a lot of machinery we don't need.
15  #
16  # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
17  
18  load("@prelude//python_bootstrap:python_bootstrap.bzl", "PythonBootstrapToolchainInfo")
19  
20  def _system_python_bootstrap_toolchain_impl(ctx):
21      return [
22          DefaultInfo(),
23          PythonBootstrapToolchainInfo(interpreter = ctx.attrs.interpreter),
24      ]
25  
26  system_python_bootstrap_toolchain = rule(
27      impl = _system_python_bootstrap_toolchain_impl,
28      attrs = {
29          "interpreter": attrs.string(default = "python3"),
30      },
31      is_toolchain_rule = True,
32  )