@@ -25,10 +25,18 @@ _OnFailure = enum(
25
25
FAIL = "fail" ,
26
26
)
27
27
28
- _TOOLCHAIN_IMPL_TEMPLATE = """\
28
+ _BUILD_BAZEL_TEMPLATE = """\
29
29
# Generated by python/private/local_runtime_repo.bzl
30
30
31
- load("@rules_python//python/private:local_runtime_repo_setup.bzl", "define_local_runtime_toolchain_impl")
31
+ load(
32
+ "@rules_python//python/private:local_runtime_repo_setup.bzl",
33
+ "define_local_runtime_toolchain_impl",
34
+ "define_local_runtime_targets",
35
+ )
36
+
37
+ package(
38
+ default_visibility = ["//visibility:public"]
39
+ )
32
40
33
41
define_local_runtime_toolchain_impl(
34
42
name = "local_runtime",
@@ -41,6 +49,8 @@ define_local_runtime_toolchain_impl(
41
49
implementation_name = "{implementation_name}",
42
50
os = "{os}",
43
51
)
52
+
53
+ define_local_runtime_targets()
44
54
"""
45
55
46
56
RUNTIME_INFO_BZL_TEMPLATE = """
@@ -175,7 +185,7 @@ def _local_runtime_repo_impl(rctx):
175
185
else :
176
186
logger .warn ("No external python libraries found." )
177
187
178
- build_bazel = _TOOLCHAIN_IMPL_TEMPLATE .format (
188
+ build_bazel = _BUILD_BAZEL_TEMPLATE .format (
179
189
major = info ["major" ],
180
190
minor = info ["minor" ],
181
191
micro = info ["micro" ],
@@ -201,7 +211,9 @@ def _local_runtime_repo_impl(rctx):
201
211
))
202
212
203
213
# Text format for `python.toolchain.python_version_file`
204
- rctx .file ("version.txt" , "{major}.{minor}" .format (** info ))
214
+ # The name `python-version` is used to match pyenv and uv naming that looks
215
+ # for a `.python-version` file.
216
+ rctx .file ("python-version" , "{major}.{minor}" .format (** info ))
205
217
206
218
local_runtime_repo = repository_rule (
207
219
implementation = _local_runtime_repo_impl ,
@@ -282,7 +294,7 @@ How to handle errors when trying to automatically determine settings.
282
294
)
283
295
284
296
def _expand_incompatible_template ():
285
- return _TOOLCHAIN_IMPL_TEMPLATE .format (
297
+ return _BUILD_BAZEL_TEMPLATE .format (
286
298
interpreter_path = "/incompatible" ,
287
299
implementation_name = "incompatible" ,
288
300
interface_library = "None" ,
0 commit comments