@@ -195,10 +195,10 @@ def _escape_filename_segment(segment):
195195            escaped  +=  "_" 
196196    return  escaped 
197197
198- def  _replace_make_variables (flag , ctx ):
199-     """Replace $(VERSION ) etc make variables in flag""" 
198+ def  _replace_make_variables (flag , variable_index ):
199+     """Replace $(XYZ ) etc make variables in flag""" 
200200    if  "$"  in  flag :
201-         for  varname , varsub  in  ctx . var .items ():
201+         for  varname , varsub  in  variable_index .items ():
202202            flag  =  flag .replace ("$(%s)"  %  varname , varsub )
203203    return  flag 
204204
@@ -207,12 +207,23 @@ def _input_file_to_arg(input_file):
207207    return  "%s;%s"  %  (py_package_lib .path_inside_wheel (input_file ), input_file .path )
208208
209209def  _py_wheel_impl (ctx ):
210-     version  =  _replace_make_variables (ctx .attr .version , ctx )
210+     # Make Variable Substitutions 
211+     variable_index  =  {}
212+     variable_index .update (ctx .var )
213+     for  dep  in  ctx .attr .deps :
214+         if  platform_common .TemplateVariableInfo  in  dep :
215+             variable_index .update (
216+                 dep [platform_common .TemplateVariableInfo ].variables ,
217+             )
218+     abi  =  _replace_make_variables (ctx .attr .abi , variable_index )
219+     python_tag  =  _replace_make_variables (ctx .attr .python_tag , variable_index )
220+     version  =  _replace_make_variables (ctx .attr .version , variable_index )
221+ 
211222    outfile  =  ctx .actions .declare_file ("-" .join ([
212223        _escape_filename_segment (ctx .attr .distribution ),
213224        _escape_filename_segment (version ),
214-         _escape_filename_segment (ctx . attr . python_tag ),
215-         _escape_filename_segment (ctx . attr . abi ),
225+         _escape_filename_segment (python_tag ),
226+         _escape_filename_segment (abi ),
216227        _escape_filename_segment (ctx .attr .platform ),
217228    ]) +  ".whl" )
218229
@@ -237,8 +248,8 @@ def _py_wheel_impl(ctx):
237248    args  =  ctx .actions .args ()
238249    args .add ("--name" , ctx .attr .distribution )
239250    args .add ("--version" , version )
240-     args .add ("--python_tag" , ctx . attr . python_tag )
241-     args .add ("--abi" , ctx . attr . abi )
251+     args .add ("--python_tag" , python_tag )
252+     args .add ("--abi" , abi )
242253    args .add ("--platform" , ctx .attr .platform )
243254    args .add ("--out" , outfile )
244255    args .add ("--name_file" , name_file )
0 commit comments