@@ -41,8 +41,8 @@ def _python_repository_impl(rctx):
41
41
42
42
platform = rctx .attr .platform
43
43
python_version = rctx .attr .python_version
44
- base_url = rctx .attr .base_url
45
- ( release_filename , url ) = get_release_url ( platform , python_version , base_url )
44
+ release_filename = rctx .attr .release_filename
45
+ url = rctx . attr . url
46
46
47
47
if release_filename .endswith (".zst" ):
48
48
rctx .download (
@@ -101,7 +101,7 @@ def _python_repository_impl(rctx):
101
101
if exec_result .return_code :
102
102
fail (exec_result .stderr )
103
103
104
- python_bin = "python.exe" if ("windows" in rctx . attr . platform ) else "bin/python3"
104
+ python_bin = "python.exe" if ("windows" in platform ) else "bin/python3"
105
105
106
106
build_content = """\
107
107
# Generated by python/repositories.bzl
@@ -155,17 +155,15 @@ py_runtime_pair(
155
155
"name" : rctx .attr .name ,
156
156
"platform" : platform ,
157
157
"python_version" : python_version ,
158
+ "release_filename" : release_filename ,
158
159
"sha256" : rctx .attr .sha256 ,
160
+ "url" : url ,
159
161
}
160
162
161
163
python_repository = repository_rule (
162
164
_python_repository_impl ,
163
165
doc = "Fetches the external tools needed for the Python toolchain." ,
164
166
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
- ),
169
167
"distutils" : attr .label (
170
168
allow_single_file = True ,
171
169
doc = "A distutils.cfg file to be included in the Python installation. " +
@@ -187,10 +185,18 @@ python_repository = repository_rule(
187
185
mandatory = True ,
188
186
values = TOOL_VERSIONS .keys () + MINOR_MAPPING .keys (),
189
187
),
188
+ "release_filename" : attr .string (
189
+ doc = "The filename of the interpreter to be downloaded" ,
190
+ mandatory = True ,
191
+ ),
190
192
"sha256" : attr .string (
191
193
doc = "The SHA256 integrity hash for the Python interpreter tarball." ,
192
194
mandatory = True ,
193
195
),
196
+ "url" : attr .string (
197
+ doc = "The URL of the interpreter to download" ,
198
+ mandatory = True ,
199
+ ),
194
200
"zstd_sha256" : attr .string (
195
201
default = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0" ,
196
202
),
@@ -229,6 +235,8 @@ def python_register_toolchains(
229
235
in python/versions.bzl will be used
230
236
**kwargs: passed to each python_repositories call.
231
237
"""
238
+ base_url = kwargs .pop ("base_url" , DEFAULT_RELEASE_BASE_URL )
239
+
232
240
if python_version in MINOR_MAPPING :
233
241
python_version = MINOR_MAPPING [python_version ]
234
242
@@ -237,6 +245,8 @@ def python_register_toolchains(
237
245
if not sha256 :
238
246
continue
239
247
248
+ (release_filename , url ) = get_release_url (platform , python_version , base_url , tool_versions )
249
+
240
250
python_repository (
241
251
name = "{name}_{platform}" .format (
242
252
name = name ,
@@ -245,6 +255,8 @@ def python_register_toolchains(
245
255
sha256 = sha256 ,
246
256
platform = platform ,
247
257
python_version = python_version ,
258
+ release_filename = release_filename ,
259
+ url = url ,
248
260
distutils = distutils ,
249
261
distutils_content = distutils_content ,
250
262
** kwargs
0 commit comments