Branch: refs/heads/main
Revision: a548803a6b9bdac3de241af1ab94c73cb8d14744
Author: arifthpe
Link: Prevent Python emitting bytecode in gen_release by arifthpe · Pull Request #29473 · chapel-lang/chapel · GitHub
Log Message:
Prevent Python emitting bytecode in gen_release (#29473)
Set PYTHONDONTWRITEBYTECODE=1 early in tarball generation in
util/buildRelease/gen_release, to prevent the creation of .pyc files
/ __pycache__ dirs.
Many uses of make in our project implicitly run printchplenv --
which invokes a Python script and thus can emit these files -- due to
its use in setting CHPL_MAKE_CHPLENV_CACHE in
make/Makefile.base.
Specifically, after make clobber removes these files in gen_release,
we then do a make tarball-prep in tools/mason (which must be after
the clobber so its desired files remain) which is enough to regenerate
the .pyc files before the commands in the tarball-prep target are
even executed. In at least the 2.9 and 2.10 tarballs these files were
present.
We could just explicitly remove these files again later, or create new
make targets just for removing them, but it seems simpler and cleaner to
me to just stop their creation at the source when generating a tarball.
PYTHONDONTWRITEBYTECODE is the way to do that, per
1. Command line and environment — Python 3.14.8 documentation.
[reviewed by @bradcray , thanks!]
Testing:
- a re-generated 2.10 tarball no longer includes any
__pycache__
dirs - observed no performance impact
Diff:
M util/buildRelease/gen_release
https://github.com/chapel-lang/chapel/pull/29473.diff