Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

"""Shared tine Python support, and the toolchain Buck2 looks up as `toolchains//`."""

load("@prelude//toolchains:python.bzl", "python_bootstrap_toolchain")
load("//python:defs.bzl", "python")

# Declared here rather than in a `toolchains` cell of its own: Buck2 forbids nesting a cell inside an
# external cell, so declaring it here is what lets a consuming project pull tine in as one.
python_bootstrap_toolchain(
python.bootstrap_toolchain(
name = "python_bootstrap",
interpreter = read_config("tine", "python_interpreter", "tine//tools:python3"),
visibility = ["PUBLIC"],
)

Expand Down
2 changes: 1 addition & 1 deletion bin/tine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3 -SIB
#!/usr/bin/env -S python3 -SIB

# SPDX-FileCopyrightText: Amutable GmbH <https://amutable.com/>
# SPDX-License-Identifier: MPL-2.0
Expand Down
13 changes: 13 additions & 0 deletions python/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load("@prelude//decls:toolchains_common.bzl", "toolchains_common")
load("@prelude//python_bootstrap:python_bootstrap.bzl", "PythonBootstrapSources")
load("@prelude//python_bootstrap:toolchain.bzl", "PythonBootstrapToolchainInfo")
load("@prelude//test:inject_test_run_info.bzl", "inject_test_run_info")
load("@prelude//toolchains:python.bzl", "python_bootstrap_toolchain", "system_python_bootstrap_toolchain")
load("@prelude//utils:selects.bzl", "selects")
load("//box:defs.bzl", "box")

Expand Down Expand Up @@ -204,8 +205,20 @@ def _test(
_python_test(name = name, box = box, srcs = srcs, deps = deps, **kwargs)
ty_check(name = name + "-ty", srcs = srcs, deps = deps, boxes = selects.apply(box, lambda value: [] if value == None else [value]))

def _bootstrap_toolchain(name: str, **kwargs) -> None:
"""Declare the bootstrap toolchain on the pinned interpreter, or on the host's `python3` if asked to.

The pinned interpreter needs a glibc loader at the standard path. A host without one sets
`tine.use_host_python = true` in the project's config.
"""
if read_root_config("tine", "use_host_python") == "true":
system_python_bootstrap_toolchain(name = name, **kwargs)
else:
python_bootstrap_toolchain(name = name, interpreter = read_config("tine", "python_interpreter", "tine//tools:python3"), **kwargs)

python = struct(
binary = _binary,
bootstrap_toolchain = _bootstrap_toolchain,
flat_tree = flat_tree,
library = _library,
test = _test,
Expand Down
2 changes: 1 addition & 1 deletion tools/ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Amutable GmbH <https://amutable.com/>
# SPDX-License-Identifier: MPL-2.0
Expand Down
Loading