cool-easter-32542
02/13/2024, 12:52 AM-OO mode).
Our binaries are built similar to this: https://www.pantsbuild.org/blog/2022/08/02/optimizing-python-docker-deploys-using-pants (For whatever reason, we couldn't get the full option to work -- the final Docker image kept failing to find third-party dependencies like awswrangler -- but we use two pex_binary() targets for srcs/deps that feed into a single docker_image().)
Here's what I've tried:
• Setting env={'PYTHONOPTIMIZE': '2'} on pex_binary() BUILD rules.
• Using ENV PYTHONOPTIMIZE=2 in the Docker image commands.
• Using ENTRYPOINT ["env", "PYTHONOPTIMIZE=2", "/bin/{name}/pex"] in the final Docker image.
• Using CMD env PYTHONOPTIMIZE=2 /bin/{name}/pex in lieu of ENTRYPOINT.
• Setting --inject-env=PYTHONOPTIMIZE=2 in the RUN PEX_TOOLS=1 invocations; it doesn't recognize the flag.
• Setting it in [subprocess-environment].env_vars in pants.toml.
None of these work -- if we point at a toy program with an assert 0 == 1, it will alway fails rather than skipping over the assertion.
Pants version
2.17.0
OS
Linux
pantsbuild/pants