Skip to content

Commit 8bed057

Browse files
committed
fix: exclude Python caches from release assets
- remove __pycache__ and bytecode files from packaged runtime trees - add a release packaging regression test for cache-free archives
1 parent 19a0196 commit 8bed057

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

scripts/release-package.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ for item in "${RELEASE_FILES[@]}"; do
5050
cp -R "$ROOT_DIR/$item" "$PACKAGE_ROOT/"
5151
done
5252

53+
find "$PACKAGE_ROOT" -type d -name "__pycache__" -prune -exec rm -rf {} +
54+
find "$PACKAGE_ROOT" -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
55+
5356
cp -f "$ROOT_DIR/README.md" "$PACKAGE_ROOT/INSTALL.md"
5457

5558
tar -czf "$DIST_DIR/${PACKAGE_NAME}.tar.gz" -C "$TMP_DIR" "$PACKAGE_NAME"

tests/test_release.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import subprocess
88
import tarfile
9+
from pathlib import Path
910
from types import SimpleNamespace
1011

1112
import git_auto_sync
@@ -169,3 +170,21 @@ def fake_download(url, dest):
169170
encoding="utf-8"
170171
) == "__version__ = '1.2.3'\n"
171172
assert config.read_text(encoding="utf-8") == "keep me\n"
173+
174+
175+
def test_release_package_excludes_python_cache_files():
176+
repo = Path(__file__).resolve().parents[1]
177+
subprocess.run(
178+
["bash", "scripts/release-package.sh", "v9.9.9"],
179+
cwd=repo,
180+
check=True,
181+
capture_output=True,
182+
text=True,
183+
)
184+
185+
archive = repo / "dist" / "git-auto-sync-v9.9.9-release.tar.gz"
186+
with tarfile.open(archive, "r:gz") as tf:
187+
names = tf.getnames()
188+
189+
assert not any("__pycache__" in name for name in names)
190+
assert not any(name.endswith(".pyc") for name in names)

0 commit comments

Comments
 (0)