Skip to content

python3: honour --no-optimize-python when byte-compiling - #3394

Open
f321x wants to merge 1 commit into
kivy:developfrom
f321x:202610_python3_honour_no_optimize
Open

f321x wants to merge 1 commit into
kivy:developfrom
f321x:202610_python3_honour_no_optimize

Conversation

@f321x

@f321x f321x commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

The flag only reached the dist's build.py, which compiles the app's --private sources. The standard library, the extension modules and site-packages are byte-compiled earlier, by the python3 recipe while the distribution is assembled, and that call hardcoded -OO. Asking for unoptimized bytecode therefore still stripped docstrings and asserts from everything except the app's own files.

Parse the flag in the toolchain as well and keep it in unknown_args so build.py still receives it, then let the recipe consult ctx.optimize_python. This follows --private and --with-debug-symbols, which are also build.py arguments that are needed before the distribution is assembled.

This is how the spesmilo fork currently patched this:
spesmilo@ecd5516

Related
#1221

The flag only reached the dist's build.py, which compiles the app's
--private sources. The standard library, the extension modules and
site-packages are byte-compiled earlier, by the python3 recipe while the
distribution is assembled, and that call hardcoded -OO. Asking for
unoptimized bytecode therefore still stripped docstrings and asserts
from everything except the app's own files.

Parse the flag in the toolchain as well and let the recipe consult
ctx.optimize_python. It goes on the generic parser, next to the other
options that control how a distribution is built, because the recipe
runs under `create` too, not only under the packaging commands. For
those it is also kept in unknown_args, so the bootstrap's build.py
keeps receiving it the way --private and --with-debug-symbols do.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 63.302% (+0.02%) from 63.278% — f321x:202610_python3_honour_no_optimize into kivy:develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants