|
16 | 16 | """ |
17 | 17 |
|
18 | 18 | load("@bazel_skylib//lib:shell.bzl", "shell") |
19 | | -load("@pythons_hub//:versions.bzl", "DEFAULT_PYTHON_VERSION", "MINOR_MAPPING") |
20 | 19 | load("//python:py_binary.bzl", "py_binary") |
21 | 20 | load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility |
22 | | -load("//python/private:full_version.bzl", "full_version") |
23 | 21 | load("//python/private:toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE") # buildifier: disable=bzl-visibility |
24 | 22 | load(":toolchain_types.bzl", "UV_TOOLCHAIN_TYPE") |
25 | 23 |
|
@@ -75,15 +73,15 @@ def _args(ctx): |
75 | 73 |
|
76 | 74 | def _lock_impl(ctx): |
77 | 75 | srcs = ctx.files.srcs |
78 | | - python_version = full_version( |
79 | | - version = ctx.attr.python_version or DEFAULT_PYTHON_VERSION, |
80 | | - minor_mapping = MINOR_MAPPING, |
81 | | - ) |
82 | | - output = ctx.actions.declare_file("{}.{}.out".format( |
83 | | - ctx.label.name, |
84 | | - python_version.replace(".", "_"), |
85 | | - )) |
| 76 | + fname = "{}.out".format(ctx.label.name) |
| 77 | + python_version = ctx.attr.python_version |
| 78 | + if python_version: |
| 79 | + fname = "{}.{}.out".format( |
| 80 | + ctx.label.name, |
| 81 | + python_version.replace(".", "_"), |
| 82 | + ) |
86 | 83 |
|
| 84 | + output = ctx.actions.declare_file(fname) |
87 | 85 | toolchain_info = ctx.toolchains[UV_TOOLCHAIN_TYPE] |
88 | 86 | uv = toolchain_info.uv_toolchain_info.uv[DefaultInfo].files_to_run.executable |
89 | 87 |
|
@@ -166,15 +164,7 @@ def _transition_impl(input_settings, attr): |
166 | 164 | _PYTHON_VERSION_FLAG: input_settings[_PYTHON_VERSION_FLAG], |
167 | 165 | } |
168 | 166 | if attr.python_version: |
169 | | - # FIXME @aignas 2025-03-20: using `full_version` is a workaround for a bug in |
170 | | - # how we order toolchains in bazel. If I set the `python_version` flag |
171 | | - # to `3.12`, I would expect the latest version to be selected, i.e. the |
172 | | - # one that is in MINOR_MAPPING, but it seems that 3.12.0 is selected, |
173 | | - # because of how the targets are ordered. |
174 | | - settings[_PYTHON_VERSION_FLAG] = full_version( |
175 | | - version = attr.python_version, |
176 | | - minor_mapping = MINOR_MAPPING, |
177 | | - ) |
| 167 | + settings[_PYTHON_VERSION_FLAG] = attr.python_version |
178 | 168 | return settings |
179 | 169 |
|
180 | 170 | _python_version_transition = transition( |
@@ -436,9 +426,6 @@ def lock( |
436 | 426 | if not BZLMOD_ENABLED: |
437 | 427 | kwargs["target_compatible_with"] = ["@platforms//:incompatible"] |
438 | 428 |
|
439 | | - # FIXME @aignas 2025-03-17: should we have one more target that transitions |
440 | | - # the python_version to ensure that if somebody calls `bazel build |
441 | | - # :requirements` that it is locked with the right `python_version`? |
442 | 429 | _lock( |
443 | 430 | name = name, |
444 | 431 | args = args, |
|
0 commit comments