30
30
"PLATFORMS" ,
31
31
"WINDOWS_NAME" ,
32
32
)
33
+ load (":full_version.bzl" , "full_version" )
33
34
load (":which.bzl" , "which_with_fail" )
34
35
35
36
def get_repository_name (repository_workspace ):
@@ -252,8 +253,12 @@ def _multi_toolchain_aliases_impl(rctx):
252
253
rules_python = rctx .attr ._rules_python_workspace .workspace_name
253
254
254
255
for python_version , repository_name in rctx .attr .python_versions .items ():
255
- file = "{}/defs.bzl" .format (python_version )
256
- rctx .file (file , content = """\
256
+ python_version = full_version (python_version )
257
+ for is_short in [False , True ]:
258
+ python_version_short , _ , _ = python_version .rpartition ("." )
259
+ v = python_version_short if is_short else python_version
260
+
261
+ rctx .file ("{}/defs.bzl" .format (v ), content = """\
257
262
# Generated by python/private/toolchains_repo.bzl
258
263
259
264
load(
@@ -266,16 +271,18 @@ load(
266
271
_py_test = "py_test",
267
272
)
268
273
274
+ {warning}
269
275
compile_pip_requirements = _compile_pip_requirements
270
276
host_platform = _host_platform
271
277
interpreter = _interpreter
272
278
py_binary = _py_binary
273
279
py_console_script_binary = _py_console_script_binary
274
280
py_test = _py_test
275
281
""" .format (
276
- repository_name = repository_name ,
277
- ))
278
- rctx .file ("{}/BUILD.bazel" .format (python_version ), "" )
282
+ repository_name = repository_name ,
283
+ warning = "" if is_short else 'print("switch to importing from \" {}:defs.bzl\" ")' .format (python_version_short ),
284
+ ))
285
+ rctx .file ("{}/BUILD.bazel" .format (v ), "" )
279
286
280
287
pip_bzl = """\
281
288
# Generated by python/private/toolchains_repo.bzl
0 commit comments