Do not write bytecode when running as root or superuser #101702
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error


Bug report
Bytecode is written by default if it does not already exist, unless
-BorPYTHONDONTWRITEBYTECODEis set/passed. This is not a problem in most cases, but in a operating system-level package building or system-level administrative context, filesystem pollution is not desirable, causing package and system integrity issues amongst other items.Many operating system-level package distributions include compiled bytecode in their packages, but this is not orthogonal to what Python's own package tooling does by default, which compiles bytecode at install time. FreeBSD ports gained trigger functionality, which, amongst other things, allows the correct operation of compiling, writing and removing bytecode at install time.
It is proposed to disable writing bytecode when running as root or superuser.
Your environment
FreeBSD-CURRENT
FreeBSD-specific context
The environment is separate between different stages of package building. The user is not necessarily root during the fetch, patch, configure, build stages, but is root for all others, including an optional interactive shell stage. Environment variables, including
PYTHONDONTWRITEBYTECODE, can only be passed per command invocation. While we have a Makefile variable that references the path to the correct Python interpreter where-Bcould theoretically be included, it does not persist during the interactive stage as it is not an environment variable.Linked PRs
The text was updated successfully, but these errors were encountered: