1# Copyright 2022 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""The Python versions we use for the toolchains. 16""" 17 18# Values returned by https://bazel.build/rules/lib/repository_os. 19MACOS_NAME = "mac os" 20LINUX_NAME = "linux" 21WINDOWS_NAME = "windows" 22 23DEFAULT_RELEASE_BASE_URL = "https://github.com/indygreg/python-build-standalone/releases/download" 24 25# When updating the versions and releases, run the following command to get 26# the hashes: 27# bazel run //python/private:print_toolchains_checksums 28# 29# Note, to users looking at how to specify their tool versions, coverage_tool version for each 30# interpreter can be specified by: 31# "3.8.10": { 32# "url": "20210506/cpython-{python_version}-{platform}-pgo+lto-20210506T0943.tar.zst", 33# "sha256": { 34# "x86_64-apple-darwin": "8d06bec08db8cdd0f64f4f05ee892cf2fcbc58cfb1dd69da2caab78fac420238", 35# "x86_64-unknown-linux-gnu": "aec8c4c53373b90be7e2131093caa26063be6d9d826f599c935c0e1042af3355", 36# }, 37# "coverage_tool": { 38# "x86_64-apple-darwin": "<label_for_darwin>"", 39# "x86_64-unknown-linux-gnu": "<label_for_linux>"", 40# }, 41# "strip_prefix": "python", 42# }, 43# 44# It is possible to provide lists in "url". 45# 46# buildifier: disable=unsorted-dict-items 47TOOL_VERSIONS = { 48 "3.8.10": { 49 "url": "20210506/cpython-{python_version}-{platform}-pgo+lto-20210506T0943.tar.zst", 50 "sha256": { 51 "x86_64-apple-darwin": "8d06bec08db8cdd0f64f4f05ee892cf2fcbc58cfb1dd69da2caab78fac420238", 52 "x86_64-unknown-linux-gnu": "aec8c4c53373b90be7e2131093caa26063be6d9d826f599c935c0e1042af3355", 53 }, 54 "strip_prefix": "python", 55 }, 56 "3.8.12": { 57 "url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz", 58 "sha256": { 59 "aarch64-apple-darwin": "f9a3cbb81e0463d6615125964762d133387d561b226a30199f5b039b20f1d944", 60 # no aarch64-unknown-linux-gnu build available for 3.8.12 61 "x86_64-apple-darwin": "f323fbc558035c13a85ce2267d0fad9e89282268ecb810e364fff1d0a079d525", 62 "x86_64-pc-windows-msvc": "4658e08a00d60b1e01559b74d58ff4dd04da6df935d55f6268a15d6d0a679d74", 63 "x86_64-unknown-linux-gnu": "5be9c6d61e238b90dfd94755051c0d3a2d8023ebffdb4b0fa4e8fedd09a6cab6", 64 }, 65 "strip_prefix": "python", 66 }, 67 "3.8.13": { 68 "url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz", 69 "sha256": { 70 "aarch64-apple-darwin": "ae4131253d890b013171cb5f7b03cadc585ae263719506f7b7e063a7cf6fde76", 71 # no aarch64-unknown-linux-gnu build available for 3.8.13 72 "x86_64-apple-darwin": "cd6e7c0a27daf7df00f6882eaba01490dd963f698e99aeee9706877333e0df69", 73 "x86_64-pc-windows-msvc": "f20643f1b3e263a56287319aea5c3888530c09ad9de3a5629b1a5d207807e6b9", 74 "x86_64-unknown-linux-gnu": "fb566629ccb5f76ef56d275a3f8017d683f1c20c5beb5d5f38b155ed11e16187", 75 }, 76 "strip_prefix": "python", 77 }, 78 "3.8.15": { 79 "url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz", 80 "sha256": { 81 "aarch64-apple-darwin": "1e0a92d1a4f5e6d4a99f86b1cbf9773d703fe7fd032590f3e9c285c7a5eeb00a", 82 "aarch64-unknown-linux-gnu": "886ab33ced13c84bf59ce8ff79eba6448365bfcafea1bf415bd1d75e21b690aa", 83 "x86_64-apple-darwin": "70b57f28c2b5e1e3dd89f0d30edd5bc414e8b20195766cf328e1b26bed7890e1", 84 "x86_64-pc-windows-msvc": "2fdc3fa1c95f982179bbbaedae2b328197658638799b6dcb63f9f494b0de59e2", 85 "x86_64-unknown-linux-gnu": "e47edfb2ceaf43fc699e20c179ec428b6f3e497cf8e2dcd8e9c936d4b96b1e56", 86 }, 87 "strip_prefix": "python", 88 }, 89 "3.8.16": { 90 "url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz", 91 "sha256": { 92 "aarch64-apple-darwin": "d1f408569d8807c1053939d7822b082a17545e363697e1ce3cfb1ee75834c7be", 93 "aarch64-unknown-linux-gnu": "15d00bc8400ed6d94c665a797dc8ed7a491ae25c5022e738dcd665cd29beec42", 94 "x86_64-apple-darwin": "484ba901f64fc7888bec5994eb49343dc3f9d00ed43df17ee9c40935aad4aa18", 95 "x86_64-pc-windows-msvc": "b446bec833eaba1bac9063bb9b4aeadfdf67fa81783b4487a90c56d408fb7994", 96 "x86_64-unknown-linux-gnu": "c890de112f1ae31283a31fefd2061d5c97bdd4d1bdd795552c7abddef2697ea1", 97 }, 98 "strip_prefix": "python", 99 }, 100 "3.9.10": { 101 "url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz", 102 "sha256": { 103 "aarch64-apple-darwin": "ad66c2a3e7263147e046a32694de7b897a46fb0124409d29d3a93ede631c8aee", 104 "aarch64-unknown-linux-gnu": "12dd1f125762f47975990ec744532a1cf3db74ad60f4dfb476ca42deb7f78ca4", 105 "x86_64-apple-darwin": "fdaf594142446029e314a9beb91f1ac75af866320b50b8b968181e592550cd68", 106 "x86_64-pc-windows-msvc": "c145d9d8143ce163670af124b623d7a2405143a3708b033b4d33eed355e61b24", 107 "x86_64-unknown-linux-gnu": "455089cc576bd9a58db45e919d1fc867ecdbb0208067dffc845cc9bbf0701b70", 108 }, 109 "strip_prefix": "python", 110 }, 111 "3.9.12": { 112 "url": "20220502/cpython-{python_version}+20220502-{platform}-{build}.tar.gz", 113 "sha256": { 114 "aarch64-apple-darwin": "8dee06c07cc6429df34b6abe091a4684a86f7cec76f5d1ccc1c3ce2bd11168df", 115 "aarch64-unknown-linux-gnu": "2ee1426c181e65133e57dc55c6a685cb1fb5e63ef02d684b8a667d5c031c4203", 116 "x86_64-apple-darwin": "2453ba7f76b3df3310353b48c881d6cff622ba06e30d2b6ae91588b2bc9e481a", 117 "x86_64-pc-windows-msvc": "3024147fd987d9e1b064a3d94932178ff8e0fe98cfea955704213c0762fee8df", 118 "x86_64-unknown-linux-gnu": "ccca12f698b3b810d79c52f007078f520d588232a36bc12ede944ec3ea417816", 119 }, 120 "strip_prefix": "python", 121 }, 122 "3.9.13": { 123 "url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz", 124 "sha256": { 125 "aarch64-apple-darwin": "d9603edc296a2dcbc59d7ada780fd12527f05c3e0b99f7545112daf11636d6e5", 126 "aarch64-unknown-linux-gnu": "80415aac1b96255b9211f6a4c300f31e9940c7e07a23d0dec12b53aa52c0d25e", 127 "x86_64-apple-darwin": "9540a7efb7c8a54a48aff1cb9480e49588d9c0a3f934ad53f5b167338174afa3", 128 "x86_64-pc-windows-msvc": "b538127025a467c64b3351babca2e4d2ea7bdfb7867d5febb3529c34456cdcd4", 129 "x86_64-unknown-linux-gnu": "ce1cfca2715e7e646dd618a8cb9baff93000e345ccc979b801fc6ccde7ce97df", 130 }, 131 "strip_prefix": "python", 132 }, 133 "3.9.15": { 134 "url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz", 135 "sha256": { 136 "aarch64-apple-darwin": "64dc7e1013481c9864152c3dd806c41144c79d5e9cd3140e185c6a5060bdc9ab", 137 "aarch64-unknown-linux-gnu": "52a8c0a67fb919f80962d992da1bddb511cdf92faf382701ce7673e10a8ff98f", 138 "x86_64-apple-darwin": "f2bcade6fc976c472f18f2b3204d67202d43ae55cf6f9e670f95e488f780da08", 139 "x86_64-pc-windows-msvc": "022daacab215679b87f0d200d08b9068a721605fa4721ebeda38220fc641ccf6", 140 "x86_64-unknown-linux-gnu": "cdc3a4cfddcd63b6cebdd75b14970e02d8ef0ac5be4d350e57ab5df56c19e85e", 141 }, 142 "strip_prefix": "python", 143 }, 144 "3.9.16": { 145 "url": "20230507/cpython-{python_version}+20230507-{platform}-{build}.tar.gz", 146 "sha256": { 147 "aarch64-apple-darwin": "c1de1d854717a6245f45262ef1bb17b09e2c587590e7e3f406593c143ff875bd", 148 "aarch64-unknown-linux-gnu": "f629b75ebfcafe9ceee2e796b7e4df5cf8dbd14f3c021afca078d159ab797acf", 149 "ppc64le-unknown-linux-gnu": "ff3ac35c58f67839aff9b5185a976abd3d1abbe61af02089f7105e876c1fe284", 150 "x86_64-apple-darwin": "3abc4d5fbbc80f5f848f280927ac5d13de8dc03aabb6ae65d8247cbb68e6f6bf", 151 "x86_64-pc-windows-msvc": "cdabb47204e96ce7ea31fbd0b5ed586114dd7d8f8eddf60a509a7f70b48a1c5e", 152 "x86_64-unknown-linux-gnu": "2b6e146234a4ef2a8946081fc3fbfffe0765b80b690425a49ebe40b47c33445b", 153 }, 154 "strip_prefix": "python", 155 }, 156 "3.9.17": { 157 "url": "20230726/cpython-{python_version}+20230726-{platform}-{build}.tar.gz", 158 "sha256": { 159 "aarch64-apple-darwin": "73dbe2d702210b566221da9265acc274ba15275c5d0d1fa327f44ad86cde9aa1", 160 "aarch64-unknown-linux-gnu": "b77012ddaf7e0673e4aa4b1c5085275a06eee2d66f33442b5c54a12b62b96cbe", 161 "ppc64le-unknown-linux-gnu": "c591a28d943dce5cf9833e916125fdfbeb3120270c4866ee214493ccb5b83c3c", 162 "s390x-unknown-linux-gnu": "01454d7cc7c9c2fccde42ba868c4f372eaaafa48049d49dd94c9cf2875f497e6", 163 "x86_64-apple-darwin": "dfe1bea92c94b9cb779288b0b06e39157c5ff7e465cdd24032ac147c2af485c0", 164 "x86_64-pc-windows-msvc": "9b9a1e21eff29dcf043cea38180cf8ca3604b90117d00062a7b31605d4157714", 165 "x86_64-unknown-linux-gnu": "26c4a712b4b8e11ed5c027db5654eb12927c02da4857b777afb98f7a930ce637", 166 }, 167 "strip_prefix": "python", 168 }, 169 "3.10.2": { 170 "url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz", 171 "sha256": { 172 "aarch64-apple-darwin": "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef", 173 "aarch64-unknown-linux-gnu": "8f351a8cc348bb45c0f95b8634c8345ec6e749e483384188ad865b7428342703", 174 "x86_64-apple-darwin": "8146ad4390710ec69b316a5649912df0247d35f4a42e2aa9615bffd87b3e235a", 175 "x86_64-pc-windows-msvc": "a1d9a594cd3103baa24937ad9150c1a389544b4350e859200b3e5c036ac352bd", 176 "x86_64-unknown-linux-gnu": "9b64eca2a94f7aff9409ad70bdaa7fbbf8148692662e764401883957943620dd", 177 }, 178 "strip_prefix": "python", 179 }, 180 "3.10.4": { 181 "url": "20220502/cpython-{python_version}+20220502-{platform}-{build}.tar.gz", 182 "sha256": { 183 "aarch64-apple-darwin": "2c99983d1e83e4b6e7411ed9334019f193fba626344a50c36fba6c25d4de78a2", 184 "aarch64-unknown-linux-gnu": "d8098c0c54546637e7516f93b13403b11f9db285def8d7abd825c31407a13d7e", 185 "x86_64-apple-darwin": "f2711eaffff3477826a401d09a013c6802f11c04c63ab3686aa72664f1216a05", 186 "x86_64-pc-windows-msvc": "bee24a3a5c83325215521d261d73a5207ab7060ef3481f76f69b4366744eb81d", 187 "x86_64-unknown-linux-gnu": "f6f871e53a7b1469c13f9bd7920ad98c4589e549acad8e5a1e14760fff3dd5c9", 188 }, 189 "strip_prefix": "python", 190 }, 191 "3.10.6": { 192 "url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz", 193 "sha256": { 194 "aarch64-apple-darwin": "efaf66acdb9a4eb33d57702607d2e667b1a319d58c167a43c96896b97419b8b7", 195 "aarch64-unknown-linux-gnu": "81625f5c97f61e2e3d7e9f62c484b1aa5311f21bd6545451714b949a29da5435", 196 "x86_64-apple-darwin": "7718411adf3ea1480f3f018a643eb0550282aefe39e5ecb3f363a4a566a9398c", 197 "x86_64-pc-windows-msvc": "91889a7dbdceea585ff4d3b7856a6bb8f8a4eca83a0ff52a73542c2e67220eaa", 198 "x86_64-unknown-linux-gnu": "55aa2190d28dcfdf414d96dc5dcea9fe048fadcd583dc3981fec020869826111", 199 }, 200 "strip_prefix": "python", 201 }, 202 "3.10.8": { 203 "url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz", 204 "sha256": { 205 "aarch64-apple-darwin": "d52b03817bd245d28e0a8b2f715716cd0fcd112820ccff745636932c76afa20a", 206 "aarch64-unknown-linux-gnu": "33170bef18c811906b738be530f934640491b065bf16c4d276c6515321918132", 207 "x86_64-apple-darwin": "525b79c7ce5de90ab66bd07b0ac1008bafa147ddc8a41bef15ffb7c9c1e9e7c5", 208 "x86_64-pc-windows-msvc": "f2b6d2f77118f06dd2ca04dae1175e44aaa5077a5ed8ddc63333c15347182bfe", 209 "x86_64-unknown-linux-gnu": "6c8db44ae0e18e320320bbaaafd2d69cde8bfea171ae2d651b7993d1396260b7", 210 }, 211 "strip_prefix": "python", 212 }, 213 "3.10.9": { 214 "url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz", 215 "sha256": { 216 "aarch64-apple-darwin": "018d05a779b2de7a476f3b3ff2d10f503d69d14efcedd0774e6dab8c22ef84ff", 217 "aarch64-unknown-linux-gnu": "2003750f40cd09d4bf7a850342613992f8d9454f03b3c067989911fb37e7a4d1", 218 "x86_64-apple-darwin": "0e685f98dce0e5bc8da93c7081f4e6c10219792e223e4b5886730fd73a7ba4c6", 219 "x86_64-pc-windows-msvc": "59c6970cecb357dc1d8554bd0540eb81ee7f6d16a07acf3d14ed294ece02c035", 220 "x86_64-unknown-linux-gnu": "d196347aeb701a53fe2bb2b095abec38d27d0fa0443f8a1c2023a1bed6e18cdf", 221 }, 222 "strip_prefix": "python", 223 }, 224 "3.10.11": { 225 "url": "20230507/cpython-{python_version}+20230507-{platform}-{build}.tar.gz", 226 "sha256": { 227 "aarch64-apple-darwin": "8348bc3c2311f94ec63751fb71bd0108174be1c4def002773cf519ee1506f96f", 228 "aarch64-unknown-linux-gnu": "c7573fdb00239f86b22ea0e8e926ca881d24fde5e5890851339911d76110bc35", 229 "ppc64le-unknown-linux-gnu": "73a9d4c89ed51be39dd2de4e235078281087283e9fdedef65bec02f503e906ee", 230 "x86_64-apple-darwin": "bd3fc6e4da6f4033ebf19d66704e73b0804c22641ddae10bbe347c48f82374ad", 231 "x86_64-pc-windows-msvc": "9c2d3604a06fcd422289df73015cd00e7271d90de28d2c910f0e2309a7f73a68", 232 "x86_64-unknown-linux-gnu": "c5bcaac91bc80bfc29cf510669ecad12d506035ecb3ad85ef213416d54aecd79", 233 }, 234 "strip_prefix": "python", 235 }, 236 "3.10.12": { 237 "url": "20230726/cpython-{python_version}+20230726-{platform}-{build}.tar.gz", 238 "sha256": { 239 "aarch64-apple-darwin": "bc66c706ea8c5fc891635fda8f9da971a1a901d41342f6798c20ad0b2a25d1d6", 240 "aarch64-unknown-linux-gnu": "fee80e221663eca5174bd794cb5047e40d3910dbeadcdf1f09d405a4c1c15fe4", 241 "ppc64le-unknown-linux-gnu": "bb5e8cb0d2e44241725fa9b342238245503e7849917660006b0246a9c97b1d6c", 242 "s390x-unknown-linux-gnu": "8d33d435ae6fb93ded7fc26798cc0a1a4f546a4e527012a1e2909cc314b332df", 243 "x86_64-apple-darwin": "8a6e3ed973a671de468d9c691ed9cb2c3a4858c5defffcf0b08969fba9c1dd04", 244 "x86_64-pc-windows-msvc": "c1a31c353ca44de7d1b1a3b6c55a823e9c1eed0423d4f9f66e617bdb1b608685", 245 "x86_64-unknown-linux-gnu": "a476dbca9184df9fc69fe6309cda5ebaf031d27ca9e529852437c94ec1bc43d3", 246 }, 247 "strip_prefix": "python", 248 }, 249 "3.11.1": { 250 "url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz", 251 "sha256": { 252 "aarch64-apple-darwin": "4918cdf1cab742a90f85318f88b8122aeaa2d04705803c7b6e78e81a3dd40f80", 253 "aarch64-unknown-linux-gnu": "debf15783bdcb5530504f533d33fda75a7b905cec5361ae8f33da5ba6599f8b4", 254 "x86_64-apple-darwin": "20a4203d069dc9b710f70b09e7da2ce6f473d6b1110f9535fb6f4c469ed54733", 255 "x86_64-pc-windows-msvc": "edc08979cb0666a597466176511529c049a6f0bba8adf70df441708f766de5bf", 256 "x86_64-unknown-linux-gnu": "02a551fefab3750effd0e156c25446547c238688a32fabde2995c941c03a6423", 257 }, 258 "strip_prefix": "python", 259 }, 260 "3.11.3": { 261 "url": "20230507/cpython-{python_version}+20230507-{platform}-{build}.tar.gz", 262 "sha256": { 263 "aarch64-apple-darwin": "09e412506a8d63edbb6901742b54da9aa7faf120b8dbdce56c57b303fc892c86", 264 "aarch64-unknown-linux-gnu": "8190accbbbbcf7620f1ff6d668e4dd090c639665d11188ce864b62554d40e5ab", 265 "ppc64le-unknown-linux-gnu": "767d24f3570b35fedb945f5ac66224c8983f2d556ab83c5cfaa5f3666e9c212c", 266 "x86_64-apple-darwin": "f710b8d60621308149c100d5175fec39274ed0b9c99645484fd93d1716ef4310", 267 "x86_64-pc-windows-msvc": "24741066da6f35a7ff67bee65ce82eae870d84e1181843e64a7076d1571e95af", 268 "x86_64-unknown-linux-gnu": "da50b87d1ec42b3cb577dfd22a3655e43a53150f4f98a4bfb40757c9d7839ab5", 269 }, 270 "strip_prefix": "python", 271 }, 272 "3.11.4": { 273 "url": "20230726/cpython-{python_version}+20230726-{platform}-{build}.tar.gz", 274 "sha256": { 275 "aarch64-apple-darwin": "cb6d2948384a857321f2aa40fa67744cd9676a330f08b6dad7070bda0b6120a4", 276 "aarch64-unknown-linux-gnu": "2e84fc53f4e90e11963281c5c871f593abcb24fc796a50337fa516be99af02fb", 277 "ppc64le-unknown-linux-gnu": "df7b92ed9cec96b3bb658fb586be947722ecd8e420fb23cee13d2e90abcfcf25", 278 "s390x-unknown-linux-gnu": "e477f0749161f9aa7887964f089d9460a539f6b4a8fdab5166f898210e1a87a4", 279 "x86_64-apple-darwin": "47e1557d93a42585972772e82661047ca5f608293158acb2778dccf120eabb00", 280 "x86_64-pc-windows-msvc": "878614c03ea38538ae2f758e36c85d2c0eb1eaaca86cd400ff8c76693ee0b3e1", 281 "x86_64-unknown-linux-gnu": "e26247302bc8e9083a43ce9e8dd94905b40d464745b1603041f7bc9a93c65d05", 282 }, 283 "strip_prefix": "python", 284 }, 285} 286 287# buildifier: disable=unsorted-dict-items 288MINOR_MAPPING = { 289 "3.8": "3.8.15", 290 "3.9": "3.9.17", 291 "3.10": "3.10.12", 292 "3.11": "3.11.4", 293} 294 295PLATFORMS = { 296 "aarch64-apple-darwin": struct( 297 compatible_with = [ 298 "@platforms//os:macos", 299 "@platforms//cpu:aarch64", 300 ], 301 os_name = MACOS_NAME, 302 # Matches the value returned from: 303 # repository_ctx.execute(["uname", "-m"]).stdout.strip() 304 arch = "arm64", 305 ), 306 "aarch64-unknown-linux-gnu": struct( 307 compatible_with = [ 308 "@platforms//os:linux", 309 "@platforms//cpu:aarch64", 310 ], 311 os_name = LINUX_NAME, 312 # Note: this string differs between OSX and Linux 313 # Matches the value returned from: 314 # repository_ctx.execute(["uname", "-m"]).stdout.strip() 315 arch = "aarch64", 316 ), 317 "ppc64le-unknown-linux-gnu": struct( 318 compatible_with = [ 319 "@platforms//os:linux", 320 "@platforms//cpu:ppc", 321 ], 322 os_name = LINUX_NAME, 323 # Note: this string differs between OSX and Linux 324 # Matches the value returned from: 325 # repository_ctx.execute(["uname", "-m"]).stdout.strip() 326 arch = "ppc64le", 327 ), 328 "s390x-unknown-linux-gnu": struct( 329 compatible_with = [ 330 "@platforms//os:linux", 331 "@platforms//cpu:s390x", 332 ], 333 os_name = LINUX_NAME, 334 # Note: this string differs between OSX and Linux 335 # Matches the value returned from: 336 # repository_ctx.execute(["uname", "-m"]).stdout.strip() 337 arch = "s390x", 338 ), 339 "x86_64-apple-darwin": struct( 340 compatible_with = [ 341 "@platforms//os:macos", 342 "@platforms//cpu:x86_64", 343 ], 344 os_name = MACOS_NAME, 345 arch = "x86_64", 346 ), 347 "x86_64-pc-windows-msvc": struct( 348 compatible_with = [ 349 "@platforms//os:windows", 350 "@platforms//cpu:x86_64", 351 ], 352 os_name = WINDOWS_NAME, 353 arch = "x86_64", 354 ), 355 "x86_64-unknown-linux-gnu": struct( 356 compatible_with = [ 357 "@platforms//os:linux", 358 "@platforms//cpu:x86_64", 359 ], 360 os_name = LINUX_NAME, 361 arch = "x86_64", 362 ), 363} 364 365def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_URL, tool_versions = TOOL_VERSIONS): 366 """Resolve the release URL for the requested interpreter version 367 368 Args: 369 platform: The platform string for the interpreter 370 python_version: The version of the intterpreter to get 371 base_url: The URL to prepend to the 'url' attr in the tool_versions dict 372 tool_versions: A dict listing the interpreter versions, their SHAs and URL 373 374 Returns: 375 A tuple of (filename, url, and archive strip prefix) 376 """ 377 378 url = tool_versions[python_version]["url"] 379 380 if type(url) == type({}): 381 url = url[platform] 382 383 if type(url) != type([]): 384 url = [url] 385 386 strip_prefix = tool_versions[python_version].get("strip_prefix", None) 387 if type(strip_prefix) == type({}): 388 strip_prefix = strip_prefix[platform] 389 390 release_filename = None 391 rendered_urls = [] 392 for u in url: 393 release_filename = u.format( 394 platform = platform, 395 python_version = python_version, 396 build = "shared-install_only" if (WINDOWS_NAME in platform) else "install_only", 397 ) 398 if "://" in release_filename: # is absolute url? 399 rendered_urls.append(release_filename) 400 else: 401 rendered_urls.append("/".join([base_url, release_filename])) 402 403 if release_filename == None: 404 fail("release_filename should be set by now; were any download URLs given?") 405 406 patches = tool_versions[python_version].get("patches", []) 407 if type(patches) == type({}): 408 if platform in patches.keys(): 409 patches = patches[platform] 410 else: 411 patches = [] 412 413 return (release_filename, rendered_urls, strip_prefix, patches) 414 415def print_toolchains_checksums(name): 416 native.genrule( 417 name = name, 418 srcs = [], 419 outs = ["print_toolchains_checksums.sh"], 420 cmd = """\ 421cat > "$@" <<'EOF' 422#!/bin/bash 423 424set -o errexit -o nounset -o pipefail 425 426echo "Fetching hashes..." 427 428{commands} 429EOF 430 """.format( 431 commands = "\n".join([ 432 _commands_for_version(python_version) 433 for python_version in TOOL_VERSIONS.keys() 434 ]), 435 ), 436 executable = True, 437 ) 438 439def _commands_for_version(python_version): 440 return "\n".join([ 441 "echo \"{python_version}: {platform}: $$(curl --location --fail {release_url_sha256} 2>/dev/null || curl --location --fail {release_url} 2>/dev/null | shasum -a 256 | awk '{{ print $$1 }}')\"".format( 442 python_version = python_version, 443 platform = platform, 444 release_url = release_url, 445 release_url_sha256 = release_url + ".sha256", 446 ) 447 for platform in TOOL_VERSIONS[python_version]["sha256"].keys() 448 for release_url in get_release_info(platform, python_version)[1] 449 ]) 450 451def gen_python_config_settings(name = ""): 452 for platform in PLATFORMS.keys(): 453 native.config_setting( 454 name = "{name}{platform}".format(name = name, platform = platform), 455 constraint_values = PLATFORMS[platform].compatible_with, 456 ) 457