Skip to content

Commit

Permalink
Exclude dist-info data from pip_repository targets (#626)
Browse files Browse the repository at this point in the history
* Exclude dist-info data from pip_repository targets

* recursive exclusion of dist-info

Co-authored-by: Matt Mackay <mattem@gmail.com>
  • Loading branch information
UebelAndre and mattem authored Feb 26, 2022
1 parent 837050b commit 6e0cb65
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
1 change: 0 additions & 1 deletion examples/pip_repository_annotations/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ write_file(
copy_executables = {"@pip_repository_annotations_example//:data/copy_executable.py": "copied_content/executable.py"},
copy_files = {"@pip_repository_annotations_example//:data/copy_file.txt": "copied_content/file.txt"},
data = [":generated_file"],
data_exclude_glob = ["*.dist-info/RECORD"],
),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,6 @@ def test_copy_executables(self):
stdout = proc.stdout.decode("utf-8").strip()
self.assertEqual(stdout, "Hello world from copied executable")

def test_data_exclude_glob(self):
current_wheel_version = "0.37.1"

r = runfiles.Create()
dist_info_dir = (
"pip_repository_annotations_example/external/{}/wheel-{}.dist-info".format(
self.wheel_pkg_dir(),
current_wheel_version,
)
)

# `WHEEL` is expected to be there to show dist-info files are included in the runfiles
wheel_path = r.Rlocation("{}/WHEEL".format(dist_info_dir))

# However, `RECORD` was explicitly excluded, so it should be missing
record_path = r.Rlocation("{}/RECORD".format(dist_info_dir))

# Because windows does not have `--enable_runfiles` on by default, the
# `runfiles.Rlocation` results will be different on this platform vs
# unix platforms. See `@rules_python//python/runfiles` for more details.
if platform.system() == "Windows":
self.assertIsNotNone(wheel_path)
self.assertIsNone(record_path)
else:
self.assertTrue(Path(wheel_path).exists())
self.assertFalse(Path(record_path).exists())


if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions python/pip_install/extract_wheels/lib/bazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def generate_build_file_contents(
"*.whl",
"**/__pycache__/**",
"**/* *",
"**/*.dist-info/**",
"**/*.py",
"**/*.pyc",
"BUILD.bazel",
Expand Down

0 comments on commit 6e0cb65

Please sign in to comment.