Re: git: f5890bd3cbc6 - main - Revert "Mk/Uses/python.mk: Fix USE_PYTHON=pep517: always compile and install bytecode"

From: Charlie Li <vishwin_at_freebsd.org>
Date: Tue, 07 Feb 2023 22:25:44 UTC
Po-Chuan Hsieh wrote:
> Let me explain it in more detail.
> While building devel/py-installer, PEP517_BUILD_CMD executes 
> flit_core.wheel and the corresponding bytecodes are generated in the 
> __pycache__ directories.
> The fs outside STAGEDIR is being changed.
> It makes build_fs_violation failure in poudriere.
> There is nothing about setuptools.
> 
> I wonder if you really tested it.
> This is the up-to-date example (a fresh checkout).
> 
This would have never been committed, or even available for "public" 
review, in the first place if I found bytecode during initial 
qualification. I can't reproduce, but probably because I don't build as 
root, not even in poudriere: $USER is nobody in configure, build, stage, 
package.

In flit_core, nothing between flit_core/wheel.py and 
bootstrap_install.py compiles any bytecode. Looks like during the 
installer build process, if $USER matches the owner of the installed 
flit_core files, bytecode gets written during every ${PYTHON_CMD} 
invocation because they were not present after install. If $USER does 
not match, bytecode is not written due to permissions errors.

The solution here is actually to explicitly disable writing bytecode on 
import, by either passing -B to ${PYTHON_CMD} or adding 
PYTHONDONTWRITEBYTECODE=whatever to MAKE_ENV.

-- 
Charlie Li
…nope, still don't have an exit line.