1010
1111WHEEL_FILE_LABEL = "whl"
1212PY_LIBRARY_LABEL = "pkg"
13+ DATA_LABEL = "data"
14+ DIST_INFO_LABEL = "dist_info"
1315
1416
1517def generate_build_file_contents (
@@ -33,14 +35,24 @@ def generate_build_file_contents(
3335
3436 return textwrap .dedent (
3537 """\
38+ load("@rules_python//python:defs.bzl", "py_library")
39+
3640 package(default_visibility = ["//visibility:public"])
3741
38- load("@rules_python//python:defs.bzl", "py_library")
42+ filegroup(
43+ name = "{dist_info_label}",
44+ srcs = glob(["*.dist-info/**"], allow_empty = True),
45+ )
46+
47+ filegroup(
48+ name = "{data_label}",
49+ srcs = glob(["*.data/**"], allow_empty = True),
50+ )
3951
4052 filegroup(
41- name= "{whl_file_label}",
42- srcs= glob(["*.whl"], allow_empty = True),
43- data= [{whl_file_deps}]
53+ name = "{whl_file_label}",
54+ srcs = glob(["*.whl"], allow_empty = True),
55+ data = [{whl_file_deps}],
4456 )
4557
4658 py_library(
@@ -58,6 +70,8 @@ def generate_build_file_contents(
5870 data_exclude = json .dumps (data_exclude ),
5971 whl_file_label = WHEEL_FILE_LABEL ,
6072 whl_file_deps = "," .join (whl_file_deps ),
73+ data_label = DATA_LABEL ,
74+ dist_info_label = DIST_INFO_LABEL ,
6175 )
6276 )
6377
@@ -92,14 +106,23 @@ def requirement(name):
92106 return "{repo}//pypi__" + name_key
93107
94108 def whl_requirement(name):
95- return requirement(name) + ":whl"
109+ return requirement(name) + ":{whl_file_label}"
110+
111+ def data_requirement(name):
112+ return requirement(name) + ":{data_label}"
113+
114+ def dist_info_requirement(name):
115+ return requirement(name) + ":{dist_info_label}"
96116
97117 def install_deps():
98118 fail("install_deps() only works if you are creating an incremental repo. Did you mean to use pip_parse()?")
99119 """ .format (
100120 repo = repo_name ,
101121 requirement_labels = requirement_labels ,
102122 whl_requirement_labels = whl_requirement_labels ,
123+ whl_file_label = WHEEL_FILE_LABEL ,
124+ data_label = DATA_LABEL ,
125+ dist_info_label = DIST_INFO_LABEL ,
103126 )
104127 )
105128
0 commit comments