thousands-plumber-33255
10/16/2025, 7:15 PMpex_binary(
name='deps',
execution_mode='venv',
include_requirements=True,
include_sources=False,
include_tools=True,
layout='packed',
env={"PYTHONWARNINGS": "ignore"},
)
FROM base AS production-deps
ARG PYTHON_MAJOR_VERSION
COPY django/production-deps.pex /deps.pex
RUN PEX_TOOLS=1 python${PYTHON_MAJOR_VERSION} /deps.pex venv --scope=deps --collisions-ok --compile --rm all /bin/production
But that still gives me all those warnings when I run the pex:
/bin/production/lib/python3.12/site-packages/pydantic/_internal/_config.py:323: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at <https://errors.pydantic.dev/2.11/migration/>
warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
I can even see in the /bin/production/pex file that it injects the envs. But why is that ignored at all?thousands-plumber-33255
10/16/2025, 7:25 PMcurved-manchester-66006
10/16/2025, 7:26 PMPYTHONWARNINGS=ignore work as you set it in the Dockerfile or manually?curved-manchester-66006
10/16/2025, 7:27 PMbrief-scientist-13682
10/16/2025, 10:01 PM___main___?brief-scientist-13682
10/16/2025, 10:02 PMthousands-plumber-33255
10/17/2025, 6:41 AMthousands-plumber-33255
10/17/2025, 7:52 AMimport os
import sys
import warnings
def run_gunicorn() -> None:
"""
Setup gunicorn and run.
"""
# If no args were provided, fill them in for convenience.
if len(sys.argv) == 1:
sys.argv.extend(['--config', 'python:gunicorn_conf'])
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_core.settings')
from gunicorn.app.wsgiapp import run
sys.exit(run())
if __name__ == '__main__':
warnings.simplefilter('ignore')
run_gunicorn()brief-scientist-13682
10/17/2025, 10:37 AMthousands-plumber-33255
10/17/2025, 11:09 AMbrief-scientist-13682
10/17/2025, 11:51 AM__main__ edit didn't do it. By the time __main__ is executing, Pex is out of the picture.
FWIW, in the original env based approach, PEXes are hermetic by default and screen all PYHTON env vars (so PYTHONPATH can't leak into the PEX sys.path). You can cancel that in the --venv case with --non-hermetic-venv-scripts .
For example:
:; pex --venv -o empty.venv.pex --seed
/home/jsirois/.cache/pex/venvs/3/e6ed52029a84b98d42fb954d4853f9d28046fe8b/485b182d3b10432d6a5f1f5be4248d540afe6b7b/pex
:; head -1 /home/jsirois/.cache/pex/venvs/3/e6ed52029a84b98d42fb954d4853f9d28046fe8b/485b182d3b10432d6a5f1f5be4248d540afe6b7b/pex
#!/home/jsirois/.cache/pex/venvs/3/s/17835cf0/venv/bin/python3.14 -sE
Versus:
:; pex --venv --non-hermetic-venv-scripts -o empty.venv.leaky.pex --seed
/home/jsirois/.cache/pex/venvs/3/cbaea3e73c7497750383af2a14361b0f3f351152/485b182d3b10432d6a5f1f5be4248d540afe6b7b/pex
:; head -1 /home/jsirois/.cache/pex/venvs/3/cbaea3e73c7497750383af2a14361b0f3f351152/485b182d3b10432d6a5f1f5be4248d540afe6b7b/pex
#!/home/jsirois/.cache/pex/venvs/3/s/0125a3f7/venv/bin/python3.14
Where -E tells python to ignore `PYTHON*`env vars.brief-scientist-13682
10/17/2025, 11:57 AMbrief-scientist-13682
10/17/2025, 12:01 PMRUN PEX_TOOLS=1 python${PYTHON_MAJOR_VERSION} /deps.pex venv --scope=deps --collisions-ok --compile --rm all /bin/production
Creates a plain old venv at /bin/production. There is 0 PEX at that point unless you run the /bin/production/pex script. You can always run /bin/production/bin/python -m my.main.module , etc to completely take Pex out of the picture and determine if it's a Pex issue or a Python issue.brief-scientist-13682
10/17/2025, 12:02 PM