Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 79cebad

Browse filesBrowse files
authored
Allow METADATA files in pip_repository generated targets (#637)
1 parent 27d0c7b commit 79cebad
Copy full SHA for 79cebad

File tree

Expand file treeCollapse file tree

3 files changed

+32
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+32
-5
lines changed

‎examples/pip_repository_annotations/WORKSPACE

Copy file name to clipboardExpand all lines: examples/pip_repository_annotations/WORKSPACE
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ write_file(
3434
copy_executables = {"@pip_repository_annotations_example//:data/copy_executable.py": "copied_content/executable.py"},
3535
copy_files = {"@pip_repository_annotations_example//:data/copy_file.txt": "copied_content/file.txt"},
3636
data = [":generated_file"],
37+
data_exclude_glob = ["*.dist-info/WHEEL"],
3738
),
3839
}
3940

‎examples/pip_repository_annotations/pip_repository_annotations_test.py

Copy file name to clipboardExpand all lines: examples/pip_repository_annotations/pip_repository_annotations_test.py
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ def test_copy_executables(self):
6464
stdout = proc.stdout.decode("utf-8").strip()
6565
self.assertEqual(stdout, "Hello world from copied executable")
6666

67+
def test_data_exclude_glob(self):
68+
current_wheel_version = "0.37.1"
69+
70+
r = runfiles.Create()
71+
dist_info_dir = (
72+
"pip_repository_annotations_example/external/{}/wheel-{}.dist-info".format(
73+
self.wheel_pkg_dir(),
74+
current_wheel_version,
75+
)
76+
)
77+
78+
# Note: `METADATA` is important as it's consumed by https://docs.python.org/3/library/importlib.metadata.html
79+
# `METADATA` is expected to be there to show dist-info files are included in the runfiles.
80+
metadata_path = r.Rlocation("{}/METADATA".format(dist_info_dir))
81+
82+
# However, `WHEEL` was explicitly excluded, so it should be missing
83+
wheel_path = r.Rlocation("{}/WHEEL".format(dist_info_dir))
84+
85+
# Because windows does not have `--enable_runfiles` on by default, the
86+
# `runfiles.Rlocation` results will be different on this platform vs
87+
# unix platforms. See `@rules_python//python/runfiles` for more details.
88+
if platform.system() == "Windows":
89+
self.assertIsNotNone(metadata_path)
90+
self.assertIsNone(wheel_path)
91+
else:
92+
self.assertTrue(Path(metadata_path).exists())
93+
self.assertFalse(Path(wheel_path).exists())
94+
6795

6896
if __name__ == "__main__":
6997
unittest.main()

‎python/pip_install/extract_wheels/lib/bazel.py

Copy file name to clipboardExpand all lines: python/pip_install/extract_wheels/lib/bazel.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ def generate_build_file_contents(
139139
there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`).
140140
"""
141141

142-
# `dist-info` contains non-determinisitc files which can change any time
143-
# the repository rules run. Below is a list of known patterns to these
144-
# files. However, not all files should be ignored as certain packages
145-
# require things like `top_level.txt`.
146142
dist_info_ignores = [
147-
"**/*.dist-info/METADATA",
143+
# RECORD is known to contain sha256 checksums of files which might include the checksums
144+
# of generated files produced when wheels are installed. The file is ignored to avoid
145+
# Bazel caching issues.
148146
"**/*.dist-info/RECORD",
149147
]
150148

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.