narrow-activity-17405
01/24/2023, 11:28 AMPYTHONOPTIMIZE
to a pex file? Some of our code depends on __debug__
- when I run PYTHONOPTIMIZE=1 python
, then __debug__
becomes false. But it seems that when I run PYTHONOPTIMIZE=1 file.pex
, __debug__
remains true. The same result with python -O file.pex
🙂 Not sure how this is supposed to work... But I would like to turn on optimizations for production images based on pex files. Thanks for hints.enough-analyst-54434
01/24/2023, 4:28 PM--venv
or else you install your PEX as a venv using pex-tools in your image, this works. You want to be doing the latter anyhow!
For more on installing a PEX file in an image instead of just running it - which is not optimal in a number of dimensions - see:
+ https://pex.readthedocs.io/en/v2.1.121/recipes.html#pex-app-in-a-container
+ https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/narrow-activity-17405
01/25/2023, 9:15 AMenough-analyst-54434
01/25/2023, 10:41 AM__debug__
sealed in.enough-analyst-54434
01/25/2023, 10:43 AMRUN PEX_TOOLS=1 PYTHON OPTIMIZE=1 ...
narrow-activity-17405
01/25/2023, 10:44 AMnarrow-activity-17405
04/03/2023, 11:29 AMif ___debug___
are still executed. The BUILD files were updated according to what you suggested. Any idea, please? 🙂 I also tried to work with a pex file without docker, but it is (obviously) the same.narrow-activity-17405
04/03/2023, 11:41 AM___pycache___
and runs the code from sources?narrow-activity-17405
04/18/2023, 2:45 PMenough-analyst-54434
04/18/2023, 2:50 PM