Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Python optimizations temporarily in final release builds to preserve assert statements and runtime checks #266

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,15 @@ def freeze(c):
with c.cd(str(PROJECT_ROOT / "scripts" / "builder")):
if app.get_version_info()["pre_type"] is None:
print(
"The current build is a final release. Turnning on python optimizations..."
"Final release detected. Python optimizations are currently disabled "
"to ensure assert statements and runtime checks are preserved."
" This is a temporary measure, and we plan to enable optimizations in future versions."
)
os.environ["PYTHONOPTIMIZE"] = "2"
# TODO: Python optimization mode is commented out to prevent removal of assert statements
# in production builds. Assert statements are crucial for ensuring runtime checks,
# and omitting them could lead to unexpected behavior or failures.
# To revisit: Determine how to handle optimizations without impacting critical runtime checks.
# os.environ["PYTHONOPTIMIZE"] = "2"
c.run(
f"pyinstaller Bookworm.spec --clean -y --distpath {c['build_folder'].parent}",
hide=False,
Expand Down