Skip to content

Commit 1a267b6

Browse files
Add signature and switch to CACHEDIR.TAG
Co-authored-by: Henry Schreiner <[email protected]>
1 parent 8e0b65e commit 1a267b6

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

cibuildwheel/__main__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ def main_inner(global_options: GlobalOptions) -> None:
208208
if not sentinel_file.exists():
209209
print(
210210
f"Error: {CIBW_CACHE_PATH} does not appear to be a cibuildwheel cache directory.",
211-
file=sys.stderr,
212-
)
213-
print(
214-
"Only directories with a .cibuildwheel_cached sentinel file can be cleaned.",
211+
"Only directories with a CACHEDIR.TAG sentinel file can be cleaned.",
212+
sep="\n",
215213
file=sys.stderr,
216214
)
217215
sys.exit(1)

cibuildwheel/util/file.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ def ensure_cache_sentinel(cache_path: Path) -> None:
2929
cache_path: The cache directory path where the sentinel should be created
3030
"""
3131
if cache_path.exists():
32-
sentinel_file = cache_path / ".cibuildwheel_cached"
32+
sentinel_file = cache_path / "CACHEDIR.TAG"
3333
if not sentinel_file.exists():
34-
sentinel_file.write_text("# Created by cibuildwheel automatically\n")
34+
sentinel_file.write_text("Signature: 8a477f597d28d172789f06886806bc55\n"
35+
"# This file is a cache directory tag created by cibuildwheel.\n")
3536

3637

3738
def download(url: str, dest: Path) -> None:

unit_test/main_commands_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def test_clean_cache_when_cache_exists(tmp_path, monkeypatch, capfd):
1515
fake_cache_dir.mkdir(parents=True, exist_ok=True)
1616
assert fake_cache_dir.exists()
1717

18-
cibw_sentinel = fake_cache_dir / ".cibuildwheel_cached"
19-
cibw_sentinel.write_text("# Created by cibuildwheel automatically", encoding="utf-8")
18+
cibw_sentinel = fake_cache_dir / "CACHEDIR.TAG"
19+
cibw_sentinel.write_text("Signature: 8a477f597d28d172789f06886806bc55\n"
20+
"# This file is a cache directory tag created by cibuildwheel.\n", encoding="utf-8")
2021

2122
dummy_file = fake_cache_dir / "dummy.txt"
2223
dummy_file.write_text("hello")
@@ -56,8 +57,9 @@ def test_clean_cache_with_error(tmp_path, monkeypatch, capfd):
5657
fake_cache_dir.mkdir(parents=True, exist_ok=True)
5758
assert fake_cache_dir.exists()
5859

59-
cibw_sentinel = fake_cache_dir / ".cibuildwheel_cached"
60-
cibw_sentinel.write_text("# Created by cibuildwheel automatically\n")
60+
cibw_sentinel = fake_cache_dir / "CACHEDIR.TAG"
61+
cibw_sentinel.write_text("Signature: 8a477f597d28d172789f06886806bc55\n"
62+
"# This file is a cache directory tag created by cibuildwheel.\n")
6163

6264
monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--clean-cache"])
6365

0 commit comments

Comments
 (0)