@@ -50,7 +50,7 @@ def _py_wheel_dist_impl(ctx):
5050 use_default_shell_env = True ,
5151 )
5252 return [
53- DefaultInfo (files = depset ([dir ])),
53+ DefaultInfo (files = depset ([dir ]), runfiles = ctx . runfiles ([ dir ]) ),
5454 ]
5555
5656py_wheel_dist = rule (
@@ -69,7 +69,7 @@ This also has the advantage that stamping information is included in the wheel's
6969 },
7070)
7171
72- def py_wheel (name , twine = None , ** kwargs ):
72+ def py_wheel (name , twine = None , publish_args = [], ** kwargs ):
7373 """Builds a Python Wheel.
7474
7575 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):
142142 Args:
143143 name: A unique name for this target.
144144 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.
145148 **kwargs: other named parameters passed to the underlying [py_wheel rule](#py_wheel_rule)
146149 """
147150 _dist_target = "{}.dist" .format (name )
@@ -158,21 +161,22 @@ def py_wheel(name, twine = None, **kwargs):
158161 if not twine .endswith (":pkg" ):
159162 fail ("twine label should look like @my_twine_repo//:pkg" )
160163 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 ))
161167
162168 # TODO: use py_binary from //python:defs.bzl after our stardoc setup is less brittle
163169 # buildifier: disable=native-py
164170 native .py_binary (
165171 name = "{}.publish" .format (name ),
166172 srcs = [twine_main ],
167- args = [
168- "upload" ,
169- "$(rootpath :{})/*" .format (_dist_target ),
170- ],
173+ args = twine_args ,
171174 data = [_dist_target ],
172175 imports = ["." ],
173176 main = twine_main ,
174177 deps = [twine ],
175178 visibility = kwargs .get ("visibility" ),
179+ ** copy_propagating_kwargs (kwargs )
176180 )
177181
178182py_wheel_rule = _py_wheel
0 commit comments