@@ -114,10 +114,18 @@ def _escape_filename_segment(segment):
114
114
escaped += "_"
115
115
return escaped
116
116
117
+ def _replace_make_variables (flag , ctx ):
118
+ """Replace $(VERSION) etc make variables in flag"""
119
+ if "$" in flag :
120
+ for varname , varsub in ctx .var .items ():
121
+ flag = flag .replace ("$(%s)" % varname , varsub )
122
+ return flag
123
+
117
124
def _py_wheel_impl (ctx ):
125
+ version = _replace_make_variables (ctx .attr .version , ctx )
118
126
outfile = ctx .actions .declare_file ("-" .join ([
119
127
_escape_filename_segment (ctx .attr .distribution ),
120
- _escape_filename_segment (ctx . attr . version ),
128
+ _escape_filename_segment (version ),
121
129
_escape_filename_segment (ctx .attr .python_tag ),
122
130
_escape_filename_segment (ctx .attr .abi ),
123
131
_escape_filename_segment (ctx .attr .platform ),
@@ -143,7 +151,7 @@ def _py_wheel_impl(ctx):
143
151
144
152
args = ctx .actions .args ()
145
153
args .add ("--name" , ctx .attr .distribution )
146
- args .add ("--version" , ctx . attr . version )
154
+ args .add ("--version" , version )
147
155
args .add ("--python_tag" , ctx .attr .python_tag )
148
156
args .add ("--python_requires" , ctx .attr .python_requires )
149
157
args .add ("--abi" , ctx .attr .abi )
@@ -298,7 +306,8 @@ Stamped targets are not rebuilt unless their dependencies change.
298
306
mandatory = True ,
299
307
doc = (
300
308
"Version number of the package. Note that this attribute " +
301
- "supports stamp format strings. Eg `1.2.3-{BUILD_TIMESTAMP}`"
309
+ "supports stamp format strings (eg. `1.2.3-{BUILD_TIMESTAMP}`) " +
310
+ "as well as 'make variables' (e.g. `1.2.3-$(VERSION)`)."
302
311
),
303
312
),
304
313
"_stamp_flag" : attr .label (
0 commit comments