@@ -20,6 +20,7 @@ For historic reasons, pip_repositories() is defined in //python:pip.bzl.
20
20
load ("//python/private:toolchains_repo.bzl" , "resolved_interpreter_os_alias" , "toolchains_repo" )
21
21
load (
22
22
":versions.bzl" ,
23
+ "DEFAULT_RELEASE_BASE_URL" ,
23
24
"MINOR_MAPPING" ,
24
25
"PLATFORMS" ,
25
26
"TOOL_VERSIONS" ,
@@ -40,7 +41,8 @@ def _python_repository_impl(rctx):
40
41
41
42
platform = rctx .attr .platform
42
43
python_version = rctx .attr .python_version
43
- (release_filename , url ) = get_release_url (platform , python_version )
44
+ base_url = rctx .attr .base_url
45
+ (release_filename , url ) = get_release_url (platform , python_version , base_url )
44
46
45
47
if release_filename .endswith (".zst" ):
46
48
rctx .download (
@@ -160,6 +162,10 @@ python_repository = repository_rule(
160
162
_python_repository_impl ,
161
163
doc = "Fetches the external tools needed for the Python toolchain." ,
162
164
attrs = {
165
+ "base_url" : attr .string (
166
+ doc = "The base URL used for releases, will be joined to the templated 'url' field in the tool_versions dict" ,
167
+ default = DEFAULT_RELEASE_BASE_URL ,
168
+ ),
163
169
"distutils" : attr .label (
164
170
allow_single_file = True ,
165
171
doc = "A distutils.cfg file to be included in the Python installation. " +
@@ -203,6 +209,7 @@ def python_register_toolchains(
203
209
python_version ,
204
210
distutils = None ,
205
211
distutils_content = None ,
212
+ tool_versions = TOOL_VERSIONS ,
206
213
** kwargs ):
207
214
"""Convenience macro for users which does typical setup.
208
215
@@ -218,13 +225,15 @@ def python_register_toolchains(
218
225
python_version: the Python version.
219
226
distutils: see the distutils attribute in the python_repository repository rule.
220
227
distutils_content: see the distutils_content attribute in the python_repository repository rule.
228
+ tool_versions: a dict containing a mapping of version with SHASUM and platform info. If not supplied, the defaults
229
+ in python/versions.bzl will be used
221
230
**kwargs: passed to each python_repositories call.
222
231
"""
223
232
if python_version in MINOR_MAPPING :
224
233
python_version = MINOR_MAPPING [python_version ]
225
234
226
235
for platform in PLATFORMS .keys ():
227
- sha256 = TOOL_VERSIONS [python_version ]["sha256" ].get (platform , None )
236
+ sha256 = tool_versions [python_version ]["sha256" ].get (platform , None )
228
237
if not sha256 :
229
238
continue
230
239
0 commit comments