# \[Chapel Merge\] Prevent Python emitting bytecode in gen\_release

**URL:** <https://chapel.discourse.group/t/chapel-merge-prevent-python-emitting-bytecode-in-gen-release/52036>\
**Category:** Commits\
**Created:** [October 2, 2026, 7:31pm UTC](https://chapel.discourse.group/t/chapel-merge-prevent-python-emitting-bytecode-in-gen-release/52036 "2026-10-02T19:31:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chapelhpcBot](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chapelhpcBot](https://chapel.discourse.group/u/chapelhpcBot)\
**Post date:** [October 2, 2026, 7:31pm UTC](https://chapel.discourse.group/t/chapel-merge-prevent-python-emitting-bytecode-in-gen-release/52036/1 "2026-10-02T19:31:55Z")

</div>

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](https://github.com/chapel-lang/chapel/pull/29473)  
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`](https://github.com/chapel-lang/chapel/blob/c45e5fc889176468512d8aa3d10d30e014988fac/make/Makefile.base#L79-L87).  
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](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE).

[reviewed by @bradcray , thanks!]

Testing:

- a re-generated 2.10 tarball no longer includes any ` __pycache__ `  
dirs
- observed no performance impact

Compare: [Comparing 092b24fee1e5daca1092799f0a7563baa79592a4...8ce6c14e241582edfd074590f0f6e0e258afdcff · chapel-lang/chapel · GitHub](https://github.com/chapel-lang/chapel/compare/092b24fee1e5daca1092799f0a7563baa79592a4...8ce6c14e241582edfd074590f0f6e0e258afdcff)

Diff:  
M util/buildRelease/gen\_release  
[https://github.com/chapel-lang/chapel/pull/29473.diff](https://github.com/chapel-lang/chapel/pull/29473.diff)
