Skip to content

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

Merged
T-Dynamos merged 1 commit into
kivy:developfrom
f321x:202610_python3_honour_no_optimize
Oct 26, 2026
Merged

T-Dynamos merged 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

@coveralls

coveralls commented Oct 16, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 63.297% (+0.02%) from 63.273% — f321x:202610_python3_honour_no_optimize into kivy:develop

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.
@f321x
f321x force-pushed the 202610_python3_honour_no_optimize branch from 7043b12 to c69dbd3 Compare October 26, 2026 16:09
@T-Dynamos
T-Dynamos merged commit 1d665d1 into kivy:develop Oct 26, 2026
39 checks passed
@f321x
f321x deleted the 202610_python3_honour_no_optimize branch October 26, 2026 21:54
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.

3 participants