From 8aca11de364e7f3b05e1aa4cec0e7e3879b78f48 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Tue, 2 Mar 2021 13:57:12 -0800 Subject: [PATCH 1/2] Use BUILD.bazel file when creating py_library rules of extracted whls --- python/pip_install/extract_wheels/lib/bazel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pip_install/extract_wheels/lib/bazel.py b/python/pip_install/extract_wheels/lib/bazel.py index ef0d6e81b0..0affa20b6d 100644 --- a/python/pip_install/extract_wheels/lib/bazel.py +++ b/python/pip_install/extract_wheels/lib/bazel.py @@ -27,7 +27,7 @@ def generate_build_file_contents( there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`). """ - data_exclude = ["*.whl", "**/*.py", "**/* *", "BUILD", "WORKSPACE"] + pip_data_exclude + data_exclude = ["*.whl", "**/*.py", "**/* *", "BUILD.bazel", "WORKSPACE"] + pip_data_exclude return textwrap.dedent( """\ @@ -184,7 +184,7 @@ def extract_wheel( '"//%s:%s"' % (sanitise_name(d), WHEEL_FILE_LABEL) for d in whl_deps ] - with open(os.path.join(directory, "BUILD"), "w") as build_file: + with open(os.path.join(directory, "BUILD.bazel"), "w") as build_file: contents = generate_build_file_contents( sanitise_name(whl.name), sanitised_dependencies, sanitised_wheel_file_dependencies, pip_data_exclude ) From fc6e631e6d44e3b6509710e663766d7f1681bf12 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Tue, 2 Mar 2021 14:08:52 -0800 Subject: [PATCH 2/2] update tests --- python/pip_install/extract_wheels/lib/whl_filegroup_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pip_install/extract_wheels/lib/whl_filegroup_test.py b/python/pip_install/extract_wheels/lib/whl_filegroup_test.py index a338a140fe..12094568c9 100644 --- a/python/pip_install/extract_wheels/lib/whl_filegroup_test.py +++ b/python/pip_install/extract_wheels/lib/whl_filegroup_test.py @@ -17,7 +17,7 @@ def test_generated_build_file_has_filegroup_target(self) -> None: )[2:] # Take off the leading // from the returned label. # Assert that the raw wheel ends up in the package. self.assertIn(wheel_name, os.listdir(generated_bazel_dir)) - with open("{}/BUILD".format(generated_bazel_dir)) as build_file: + with open("{}/BUILD.bazel".format(generated_bazel_dir)) as build_file: build_file_content = build_file.read() self.assertIn('filegroup', build_file_content)