|
27 | 27 | "//python:versions.bzl",
|
28 | 28 | "LINUX_NAME",
|
29 | 29 | "MACOS_NAME",
|
| 30 | + "MINOR_MAPPING", |
30 | 31 | "PLATFORMS",
|
| 32 | + "TOOL_VERSIONS", |
31 | 33 | "WINDOWS_NAME",
|
32 | 34 | )
|
33 | 35 |
|
@@ -150,27 +152,35 @@ def _toolchain_aliases_impl(rctx):
|
150 | 152 | is_windows = (os_name == WINDOWS_NAME)
|
151 | 153 | python3_binary_path = "python.exe" if is_windows else "bin/python3"
|
152 | 154 |
|
| 155 | + # uncertain if we need to do this check or not |
| 156 | + # TODO use the code that is inbound on #1340 |
| 157 | + full_python_version = rctx.attr.python_version |
| 158 | + if TOOL_VERSIONS.get(full_python_version) == None: |
| 159 | + full_python_version = MINOR_MAPPING[full_python_version] |
| 160 | + |
153 | 161 | # Base BUILD file for this repository.
|
154 | 162 | build_contents = """\
|
155 | 163 | # Generated by python/private/toolchains_repo.bzl
|
156 | 164 | package(default_visibility = ["//visibility:public"])
|
157 |
| -load("@rules_python//python:versions.bzl", "PLATFORMS", "gen_python_config_settings") |
| 165 | +load("@rules_python//python:versions.bzl", "TOOL_VERSIONS", "gen_python_config_settings") |
158 | 166 | gen_python_config_settings()
|
159 | 167 | exports_files(["defs.bzl"])
|
160 |
| -alias(name = "files", actual = select({{":" + item: "@{py_repository}_" + item + "//:files" for item in PLATFORMS.keys()}})) |
161 |
| -alias(name = "includes", actual = select({{":" + item: "@{py_repository}_" + item + "//:includes" for item in PLATFORMS.keys()}})) |
162 |
| -alias(name = "libpython", actual = select({{":" + item: "@{py_repository}_" + item + "//:libpython" for item in PLATFORMS.keys()}})) |
163 |
| -alias(name = "py3_runtime", actual = select({{":" + item: "@{py_repository}_" + item + "//:py3_runtime" for item in PLATFORMS.keys()}})) |
164 |
| -alias(name = "python_headers", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_headers" for item in PLATFORMS.keys()}})) |
165 |
| -alias(name = "python_runtimes", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in PLATFORMS.keys()}})) |
166 |
| -alias(name = "python3", actual = select({{":" + item: "@{py_repository}_" + item + "//:" + ("python.exe" if "windows" in item else "bin/python3") for item in PLATFORMS.keys()}})) |
| 168 | +alias(name = "files", actual = select({{":" + item: "@{py_repository}_" + item + "//:files" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 169 | +alias(name = "includes", actual = select({{":" + item: "@{py_repository}_" + item + "//:includes" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 170 | +alias(name = "libpython", actual = select({{":" + item: "@{py_repository}_" + item + "//:libpython" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 171 | +alias(name = "py3_runtime", actual = select({{":" + item: "@{py_repository}_" + item + "//:py3_runtime" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 172 | +alias(name = "python_headers", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_headers" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 173 | +alias(name = "python_runtimes", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
| 174 | +alias(name = "python3", actual = select({{":" + item: "@{py_repository}_" + item + "//:" + ("python.exe" if "windows" in item else "bin/python3") for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys()}})) |
167 | 175 | """.format(
|
| 176 | + full_python_version = full_python_version, |
168 | 177 | py_repository = rctx.attr.user_repository_name,
|
169 | 178 | )
|
170 | 179 | if not is_windows:
|
171 | 180 | build_contents += """\
|
172 |
| -alias(name = "pip", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in PLATFORMS.keys() if "windows" not in item}})) |
| 181 | +alias(name = "pip", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in TOOL_VERSIONS['{full_python_version}']['sha256'].keys() if "windows" not in item}})) |
173 | 182 | """.format(
|
| 183 | + full_python_version = full_python_version, |
174 | 184 | py_repository = rctx.attr.user_repository_name,
|
175 | 185 | host_platform = host_platform,
|
176 | 186 | )
|
|
0 commit comments