@@ -288,8 +288,8 @@ def _create_whl_repos(
288288 src = src ,
289289 whl_library_args = whl_library_args ,
290290 download_only = pip_attr .download_only ,
291- netrc = pip_attr .netrc ,
292- auth_patterns = pip_attr .auth_patterns ,
291+ netrc = config . netrc or pip_attr .netrc ,
292+ auth_patterns = config . auth_patterns or pip_attr .auth_patterns ,
293293 python_version = major_minor ,
294294 is_multiple_versions = whl .is_multiple_versions ,
295295 enable_pipstar = config .enable_pipstar ,
@@ -376,7 +376,7 @@ def _whl_repo(*, src, whl_library_args, is_multiple_versions, download_only, net
376376 ),
377377 )
378378
379- def _configure (config , * , platform , os_name , arch_name , config_settings , env = {}, override = False ):
379+ def _configure (config , * , platform , os_name , arch_name , config_settings , env = {}, netrc = None , auth_patterns = None , override = False ):
380380 """Set the value in the config if the value is provided"""
381381 config .setdefault ("platforms" , {})
382382 if platform and (os_name or arch_name or config_settings or env ):
@@ -402,9 +402,16 @@ def _configure(config, *, platform, os_name, arch_name, config_settings, env = {
402402 continue
403403
404404 config ["platforms" ][platform ][key ] = value
405- else :
405+ elif platform and override :
406406 config ["platforms" ].pop (platform )
407407
408+ for key , value in {
409+ "auth_patterns" : auth_patterns ,
410+ "netrc" : netrc ,
411+ }.items ():
412+ if value and (override or key not in config ):
413+ config [key ] = value
414+
408415def _plat (* , name , arch_name , os_name , config_settings = [], env = {}):
409416 return struct (
410417 name = name ,
@@ -441,21 +448,23 @@ def build_config(
441448 _configure (
442449 defaults ,
443450 arch_name = tag .arch_name ,
451+ auth_patterns = tag .auth_patterns ,
444452 config_settings = tag .config_settings ,
445453 env = tag .env ,
454+ netrc = tag .netrc ,
446455 os_name = tag .os_name ,
447- platform = platform ,
448456 override = mod .is_root ,
457+ platform = platform ,
449458 # TODO @aignas 2025-05-19: add more attr groups:
450- # * for AUTH - the default `netrc` usage could be configured through a common
451- # attribute.
452459 # * for index/downloader config. This includes all of those attributes for
453460 # overrides, etc. Index overrides per platform could be also used here.
454461 # * for whl selection - selecting preferences of which `platform_tag`s we should use
455462 # for what. We could also model the `cp313t` freethreaded as separate platforms.
456463 )
457464
458465 return struct (
466+ auth_patterns = defaults .get ("auth_patterns" , {}),
467+ netrc = defaults .get ("netrc" , None ),
459468 platforms = {
460469 name : _plat (** values )
461470 for name , values in defaults ["platforms" ].items ()
@@ -858,7 +867,7 @@ This is only used if the {envvar}`RULES_PYTHON_ENABLE_PIPSTAR` is enabled.
858867""" ,
859868 ),
860869 # The values for PEP508 env marker evaluation during the lock file parsing
861- }
870+ } | AUTH_ATTRS
862871
863872_SUPPORTED_PEP508_KEYS = [
864873 "implementation_name" ,
0 commit comments