@@ -20,6 +20,7 @@ For historic reasons, pip_repositories() is defined in //python:pip.bzl.
2020load ("//python/private:toolchains_repo.bzl" , "resolved_interpreter_os_alias" , "toolchains_repo" )
2121load (
2222 ":versions.bzl" ,
23+ "DEFAULT_RELEASE_BASE_URL" ,
2324 "MINOR_MAPPING" ,
2425 "PLATFORMS" ,
2526 "TOOL_VERSIONS" ,
@@ -40,7 +41,8 @@ def _python_repository_impl(rctx):
4041
4142 platform = rctx .attr .platform
4243 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 )
4446
4547 if release_filename .endswith (".zst" ):
4648 rctx .download (
@@ -160,6 +162,10 @@ python_repository = repository_rule(
160162 _python_repository_impl ,
161163 doc = "Fetches the external tools needed for the Python toolchain." ,
162164 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+ ),
163169 "distutils" : attr .label (
164170 allow_single_file = True ,
165171 doc = "A distutils.cfg file to be included in the Python installation. " +
@@ -203,6 +209,7 @@ def python_register_toolchains(
203209 python_version ,
204210 distutils = None ,
205211 distutils_content = None ,
212+ tool_versions = TOOL_VERSIONS ,
206213 ** kwargs ):
207214 """Convenience macro for users which does typical setup.
208215
@@ -218,13 +225,15 @@ def python_register_toolchains(
218225 python_version: the Python version.
219226 distutils: see the distutils attribute in the python_repository repository rule.
220227 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
221230 **kwargs: passed to each python_repositories call.
222231 """
223232 if python_version in MINOR_MAPPING :
224233 python_version = MINOR_MAPPING [python_version ]
225234
226235 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 )
228237 if not sha256 :
229238 continue
230239
0 commit comments