File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
examples/pip_repository_annotations Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
6896if __name__ == "__main__" :
6997 unittest .main ()
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments