@@ -50,7 +50,7 @@ def _py_wheel_dist_impl(ctx):
50
50
use_default_shell_env = True ,
51
51
)
52
52
return [
53
- DefaultInfo (files = depset ([dir ])),
53
+ DefaultInfo (files = depset ([dir ]), runfiles = ctx . runfiles ([ dir ]) ),
54
54
]
55
55
56
56
py_wheel_dist = rule (
@@ -69,7 +69,7 @@ This also has the advantage that stamping information is included in the wheel's
69
69
},
70
70
)
71
71
72
- def py_wheel (name , twine = None , ** kwargs ):
72
+ def py_wheel (name , twine = None , publish_args = [], ** kwargs ):
73
73
"""Builds a Python Wheel.
74
74
75
75
Wheels are Python distribution format defined in https://www.python.org/dev/peps/pep-0427/.
@@ -142,6 +142,9 @@ def py_wheel(name, twine = None, **kwargs):
142
142
Args:
143
143
name: A unique name for this target.
144
144
twine: A label of the external location of the py_library target for twine
145
+ publish_args: arguments passed to twine, e.g. ["--repository-url", "https://pypi.my.org/simple/"].
146
+ These are subject to make var expansion, as with the `args` attribute.
147
+ Note that you can also pass additional args to the bazel run command as in the example above.
145
148
**kwargs: other named parameters passed to the underlying [py_wheel rule](#py_wheel_rule)
146
149
"""
147
150
_dist_target = "{}.dist" .format (name )
@@ -158,21 +161,22 @@ def py_wheel(name, twine = None, **kwargs):
158
161
if not twine .endswith (":pkg" ):
159
162
fail ("twine label should look like @my_twine_repo//:pkg" )
160
163
twine_main = twine .replace (":pkg" , ":rules_python_wheel_entry_point_twine.py" )
164
+ twine_args = ["upload" ]
165
+ twine_args .extend (publish_args )
166
+ twine_args .append ("$(rootpath :{})/*" .format (_dist_target ))
161
167
162
168
# TODO: use py_binary from //python:defs.bzl after our stardoc setup is less brittle
163
169
# buildifier: disable=native-py
164
170
native .py_binary (
165
171
name = "{}.publish" .format (name ),
166
172
srcs = [twine_main ],
167
- args = [
168
- "upload" ,
169
- "$(rootpath :{})/*" .format (_dist_target ),
170
- ],
173
+ args = twine_args ,
171
174
data = [_dist_target ],
172
175
imports = ["." ],
173
176
main = twine_main ,
174
177
deps = [twine ],
175
178
visibility = kwargs .get ("visibility" ),
179
+ ** copy_propagating_kwargs (kwargs )
176
180
)
177
181
178
182
py_wheel_rule = _py_wheel
0 commit comments