@@ -103,6 +103,7 @@ whl_library_targets_from_requires(
103103 "data_exclude_all",
104104 ],
105105 dep_template = "@pypi//{name}:{target}",
106+ enable_implicit_namespace_pkgs = True,
106107 entry_points = {
107108 "foo": "bar.py",
108109 },
@@ -139,6 +140,7 @@ whl_library_targets_from_requires(
139140 data_exclude_glob = ["data_exclude_all" ],
140141 srcs_exclude_glob = ["srcs_exclude_all" ],
141142 additive_build_content = """# SOMETHING SPECIAL AT THE END""" ,
143+ enable_implicit_namespace_pkgs = True ,
142144 ),
143145 group_name = "qux" ,
144146 group_deps = ["foo" , "fox" , "qux" ],
@@ -211,95 +213,6 @@ whl_library_targets_from_requires(
211213
212214_tests .append (_test_all_with_loads )
213215
214- def _test_enable_implicit_namespace_pkgs_annotation (env ):
215- want = """\
216- load("@rules_python//python/private/pypi:whl_library_targets.bzl", "whl_library_targets")
217-
218- package(default_visibility = ["//visibility:public"])
219-
220- whl_library_targets(
221- dep_template = "@pypi//{name}:{target}",
222- dependencies = ["foo"],
223- dependencies_by_platform = {
224- "baz": ["bar"],
225- },
226- enable_implicit_namespace_pkgs = True,
227- entry_points = {
228- "foo": "bar.py",
229- },
230- group_deps = [
231- "foo",
232- "fox",
233- "qux",
234- ],
235- group_name = "qux",
236- name = "foo.whl",
237- tags = ["tag1"],
238- )
239- """
240- actual = generate_whl_library_build_bazel (
241- dep_template = "@pypi//{name}:{target}" ,
242- name = "foo.whl" ,
243- dependencies = ["foo" ],
244- dependencies_by_platform = {"baz" : ["bar" ]},
245- entry_points = {
246- "foo" : "bar.py" ,
247- },
248- annotation = struct (
249- enable_implicit_namespace_pkgs = True ,
250- ),
251- group_name = "qux" ,
252- group_deps = ["foo" , "fox" , "qux" ],
253- tags = ["tag1" ],
254- )
255- env .expect .that_str (actual .replace ("@@" , "@" )).equals (want )
256-
257- _tests .append (_test_enable_implicit_namespace_pkgs_annotation )
258-
259- def _test_enable_implicit_namespace_pkgs_annotation_false (env ):
260- want = """\
261- load("@rules_python//python/private/pypi:whl_library_targets.bzl", "whl_library_targets")
262-
263- package(default_visibility = ["//visibility:public"])
264-
265- whl_library_targets(
266- dep_template = "@pypi//{name}:{target}",
267- dependencies = ["foo"],
268- dependencies_by_platform = {
269- "baz": ["bar"],
270- },
271- enable_implicit_namespace_pkgs = False,
272- entry_points = {
273- "foo": "bar.py",
274- },
275- group_deps = [
276- "foo",
277- "fox",
278- "qux",
279- ],
280- group_name = "qux",
281- name = "foo.whl",
282- tags = ["tag1"],
283- )
284- """
285- actual = generate_whl_library_build_bazel (
286- dep_template = "@pypi//{name}:{target}" ,
287- name = "foo.whl" ,
288- dependencies = ["foo" ],
289- dependencies_by_platform = {"baz" : ["bar" ]},
290- entry_points = {
291- "foo" : "bar.py" ,
292- },
293- annotation = struct (
294- enable_implicit_namespace_pkgs = False ,
295- ),
296- group_name = "qux" ,
297- group_deps = ["foo" , "fox" , "qux" ],
298- tags = ["tag1" ],
299- )
300- env .expect .that_str (actual .replace ("@@" , "@" )).equals (want )
301-
302- _tests .append (_test_enable_implicit_namespace_pkgs_annotation_false )
303216
304217def generate_whl_library_build_bazel_test_suite (name ):
305218 """Create the test suite.
0 commit comments