build: Enable incompatible_no_implicit_file_export in bazelrc (#3477)
Identified by
https://github.com/bazelbuild/bazel/pull/27674#issuecomment-3686476093,
I want to see what else fails when flipping this flag on top of
https://github.com/bazel-contrib/rules_python/pull/3471.
diff --git a/.bazelrc b/.bazelrc
index 718f830..2467657 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -38,5 +38,6 @@
build:rtd --enable_bzlmod
common --incompatible_python_disallow_native_rules
+common --incompatible_no_implicit_file_export
build --lockfile_mode=update
diff --git a/python/private/pypi/BUILD.bazel b/python/private/pypi/BUILD.bazel
index aa96cf8..96ae42f 100644
--- a/python/private/pypi/BUILD.bazel
+++ b/python/private/pypi/BUILD.bazel
@@ -23,6 +23,11 @@
visibility = ["//visibility:public"],
)
+exports_files(
+ srcs = ["deps.bzl"],
+ visibility = ["//tools/private/update_deps:__pkg__"],
+)
+
filegroup(
name = "distribution",
srcs = glob(
diff --git a/python/private/pypi/generate_whl_library_build_bazel.bzl b/python/private/pypi/generate_whl_library_build_bazel.bzl
index e207f6d..fbabe2e 100644
--- a/python/private/pypi/generate_whl_library_build_bazel.bzl
+++ b/python/private/pypi/generate_whl_library_build_bazel.bzl
@@ -100,6 +100,18 @@
])
additional_content = []
+ entry_points = kwargs.get("entry_points")
+ if entry_points:
+ entry_point_files = sorted({
+ entry_point_script.replace("\\", "/"): True
+ for entry_point_script in entry_points.values()
+ }.keys())
+ additional_content.append(
+ "exports_files(\n" +
+ " srcs = {},\n".format(render.list(entry_point_files)) +
+ " visibility = [\"//visibility:public\"],\n" +
+ ")\n",
+ )
if annotation:
kwargs["data"] = annotation.data
kwargs["copy_files"] = annotation.copy_files
diff --git a/tests/pypi/generate_whl_library_build_bazel/generate_whl_library_build_bazel_tests.bzl b/tests/pypi/generate_whl_library_build_bazel/generate_whl_library_build_bazel_tests.bzl
index 39c2eb4..85e96be 100644
--- a/tests/pypi/generate_whl_library_build_bazel/generate_whl_library_build_bazel_tests.bzl
+++ b/tests/pypi/generate_whl_library_build_bazel/generate_whl_library_build_bazel_tests.bzl
@@ -56,6 +56,11 @@
tags = ["tag1"],
)
+exports_files(
+ srcs = ["bar.py"],
+ visibility = ["//visibility:public"],
+)
+
# SOMETHING SPECIAL AT THE END
"""
actual = generate_whl_library_build_bazel(
@@ -122,6 +127,11 @@
srcs_exclude = ["srcs_exclude_all"],
)
+exports_files(
+ srcs = ["bar.py"],
+ visibility = ["//visibility:public"],
+)
+
# SOMETHING SPECIAL AT THE END
"""
actual = generate_whl_library_build_bazel(
@@ -187,6 +197,11 @@
srcs_exclude = ["srcs_exclude_all"],
)
+exports_files(
+ srcs = ["bar.py"],
+ visibility = ["//visibility:public"],
+)
+
# SOMETHING SPECIAL AT THE END
"""
actual = generate_whl_library_build_bazel(
@@ -252,6 +267,11 @@
srcs_exclude = ["srcs_exclude_all"],
)
+exports_files(
+ srcs = ["bar.py"],
+ visibility = ["//visibility:public"],
+)
+
# SOMETHING SPECIAL AT THE END
"""
actual = generate_whl_library_build_bazel(