@@ -79,6 +79,7 @@ def generate_build_file_contents(
7979 dependencies : List [str ],
8080 whl_file_deps : List [str ],
8181 pip_data_exclude : List [str ],
82+ tags : List [str ],
8283 additional_targets : List [str ] = [],
8384) -> str :
8485 """Generate a BUILD file for an unzipped Wheel
@@ -87,6 +88,8 @@ def generate_build_file_contents(
8788 name: the target name of the py_library
8889 dependencies: a list of Bazel labels pointing to dependencies of the library
8990 whl_file_deps: a list of Bazel labels pointing to wheel file dependencies of this wheel.
91+ pip_data_exclude: more patterns to exclude from the data attribute of generated py_library rules.
92+ tags: list of tags to apply to generated py_library rules.
9093 additional_targets: A list of additional targets to append to the BUILD file contents.
9194
9295 Returns:
@@ -143,13 +146,15 @@ def generate_build_file_contents(
143146 # search path for anything that depends on this.
144147 imports = ["."],
145148 deps = [{dependencies}],
149+ tags = [{tags}],
146150 )
147151 """ .format (
148152 name = name ,
149153 dependencies = "," .join (dependencies ),
150154 data_exclude = json .dumps (data_exclude ),
151155 whl_file_label = WHEEL_FILE_LABEL ,
152156 whl_file_deps = "," .join (whl_file_deps ),
157+ tags = "," .join (["\" %s\" " % t for t in tags ]),
153158 data_label = DATA_LABEL ,
154159 dist_info_label = DIST_INFO_LABEL ,
155160 entry_point_prefix = WHEEL_ENTRY_POINT_PREFIX ,
@@ -367,6 +372,7 @@ def extract_wheel(
367372 sanitised_dependencies ,
368373 sanitised_wheel_file_dependencies ,
369374 pip_data_exclude ,
375+ ["pypi_name=" + whl .name , "pypi_version=" + whl .metadata .version ],
370376 entry_points ,
371377 )
372378 build_file .write (contents )
0 commit comments