@@ -175,7 +175,8 @@ def process_modules(
175175 hub_name = "uv" ,
176176 uv_repository = uv_repository ,
177177 toolchain_type = str (UV_TOOLCHAIN_TYPE ),
178- hub_repo = uv_toolchains_repo ):
178+ hub_repo = uv_toolchains_repo ,
179+ get_auth = get_auth ):
179180 """Parse the modules to get the config for 'uv' toolchains.
180181
181182 Args:
@@ -184,17 +185,16 @@ def process_modules(
184185 uv_repository: the rule to create a uv_repository override.
185186 toolchain_type: the toolchain type to use here.
186187 hub_repo: the hub repo factory function to use.
188+ get_auth: the auth function to use.
187189
188190 Returns:
189191 the result of the hub_repo. Mainly used for tests.
190192 """
191193
192194 # default values to apply for version specific config
193195 defaults = {
194- "auth_patterns" : {},
195196 "base_url" : "" ,
196197 "manifest_filename" : "" ,
197- "netrc" : "" ,
198198 "platforms" : {
199199 # The structure is as follows:
200200 # "platform_name": struct(
@@ -259,10 +259,8 @@ def process_modules(
259259 specific_config = versions .setdefault (
260260 last_version ,
261261 {
262- "auth_patterns" : defaults ["auth_patterns" ],
263262 "base_url" : defaults ["base_url" ],
264263 "manifest_filename" : defaults ["manifest_filename" ],
265- "netrc" : defaults ["netrc" ],
266264 # shallow copy is enough as the values are structs and will
267265 # be replaced on modification
268266 "platforms" : dict (defaults ["platforms" ]),
@@ -311,6 +309,11 @@ def process_modules(
311309 for platform , src in config .get ("urls" , {}).items ()
312310 if src .urls
313311 }
312+ auth = {
313+ "auth_patterns" : config .get ("auth_patterns" ),
314+ "netrc" : config .get ("netrc" ),
315+ }
316+ auth = {k : v for k , v in auth .items () if v }
314317
315318 # Or fallback to fetching them from GH manifest file
316319 # Example file: https://github.com/astral-sh/uv/releases/download/0.6.3/dist-manifest.json
@@ -323,10 +326,8 @@ def process_modules(
323326 ),
324327 manifest_filename = config ["manifest_filename" ],
325328 platforms = sorted (platforms ),
326- attr = struct (
327- netrc = config ["netrc" ],
328- auth_patterns = config ["auth_patterns" ],
329- ),
329+ attr = struct (** auth ),
330+ get_auth = get_auth ,
330331 )
331332
332333 for platform_name , platform in platforms .items ():
@@ -341,8 +342,7 @@ def process_modules(
341342 platform = platform_name ,
342343 urls = urls [platform_name ].urls ,
343344 sha256 = urls [platform_name ].sha256 ,
344- auth_patterns = config ["auth_patterns" ],
345- netrc = config ["netrc" ],
345+ ** auth
346346 )
347347
348348 toolchain_names .append (toolchain_name )
@@ -379,7 +379,7 @@ def _overlap(first_collection, second_collection):
379379
380380 return False
381381
382- def _get_tool_urls_from_dist_manifest (module_ctx , * , base_url , manifest_filename , platforms , attr ):
382+ def _get_tool_urls_from_dist_manifest (module_ctx , * , base_url , manifest_filename , platforms , attr , get_auth = get_auth ):
383383 """Download the results about remote tool sources.
384384
385385 This relies on the tools using the cargo packaging to infer the actual
0 commit comments