| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| """Python toolchain definition for our prebuilt Python3 executable.""" |
| |
| load("//:fuchsia_build_config.bzl", "build_config") |
| load("@rules_python//python:defs.bzl", "py_runtime_pair") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| _python3_interpreter_path = "prebuilt/third_party/python3/%s/bin/python3" % build_config.host_tag |
| |
| py_runtime( |
| name = "py3_runtime", |
| files = ["//:prebuilt_python_files"], |
| interpreter = "//:%s" % _python3_interpreter_path, |
| python_version = "PY3", |
| # Set stub_shebang so the Python wrapper can find the prebuilt Python |
| # interpreter. |
| # |
| # See details about this shebang line in https://fxbug.dev/115164#c29, and |
| # general information about the underlying issue in that bug. |
| stub_shebang = '#!/usr/bin/env -S /bin/bash -c \'"$0".runfiles/main/%s "$0" "$@"\'' % _python3_interpreter_path, |
| ) |
| |
| py_runtime_pair( |
| name = "runtime_pair", |
| py3_runtime = ":py3_runtime", |
| ) |
| |
| toolchain( |
| name = "py_toolchain", |
| exec_compatible_with = [ |
| build_config.host_platform_os_constraint, |
| build_config.host_platform_cpu_constraint, |
| ], |
| target_compatible_with = [ |
| build_config.host_platform_os_constraint, |
| build_config.host_platform_cpu_constraint, |
| ], |
| toolchain = ":runtime_pair", |
| toolchain_type = "@rules_python//python:toolchain_type", |
| ) |