@@ -62,6 +62,12 @@ def _whl_mods_impl(whl_mods_dict):
6262 whl_mods = whl_mods ,
6363 )
6464
65+ def _set_or_fail (d , key , value , msg ):
66+ if key in d :
67+ fail (msg (key , d [key ], value ))
68+
69+ d [key ] = value
70+
6571def _create_whl_repos (
6672 module_ctx ,
6773 * ,
@@ -255,7 +261,12 @@ def _create_whl_repos(
255261 if len (requirements ) > 1 :
256262 target_platforms = requirement .target_platforms
257263
258- whl_libraries [repo_name ] = dict (whl_library_args .items ())
264+ _set_or_fail (
265+ whl_libraries ,
266+ repo_name ,
267+ dict (whl_library_args .items ()), # make a copy
268+ lambda key , existing , new : "A value for {} already exists.\n Existing:\n {}\n New:\n {}" .format (key , existing , new ),
269+ )
259270
260271 whl_map .setdefault (whl_name , []).append (
261272 whl_alias (
@@ -293,7 +304,12 @@ def _create_whl_repos(
293304 # We sort so that the lock-file remains the same no matter the order of how the
294305 # args are manipulated in the code going before.
295306 repo_name = "{}_{}" .format (pip_name , whl_name )
296- whl_libraries [repo_name ] = dict (whl_library_args .items ())
307+ _set_or_fail (
308+ whl_libraries ,
309+ repo_name ,
310+ dict (whl_library_args .items ()), # make a copy
311+ lambda key , existing , new : "A value for {} already exists.\n Existing:\n {}\n New:\n {}" .format (key , existing , new ),
312+ )
297313 whl_map .setdefault (whl_name , []).append (
298314 whl_alias (
299315 repo = repo_name ,
0 commit comments