Hi! Within our project, we used to just copy pex f...
# general
n
Hi! Within our project, we used to just copy pex files into Docker images. Now I tried to implement the "Simple Multi-Stage Build" approach from https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/. The thing is that it works for some of my images and not for others 🙂 I got quite confusing messages from Pants - first, I thought that there was some problem with dependency inference (see screen), but it turned out that it might be related to a problem with 3rd party dependency (fonttools?) - I tried to run
RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /binary.pex venv --scope=deps --compile /bin/app
outside of Pants/Docker and got this (selected the interesting part):
Copy code
$ PEX_VERBOSE=9 PEX_TOOLS=1 python dist/src.python.arcor2_calibration.scripts/calibration.pex venv --scope=deps --compile appTest
pex: Laying out Spread PEX directory /home/zdenal/arcor2_repos/arcor2/dist/src.python.arcor2_calibration.scripts/calibration.pex: 0.1ms
pex: Executing installed PEX for /home/zdenal/arcor2_repos/arcor2/dist/src.python.arcor2_calibration.scripts/calibration.pex at /home/zdenal/.pex/unzipped_pexes/b1de9cb1dc137d74acdc0779598b9da266d9abcc
...
pex: Re-writing /home/zdenal/arcor2_repos/arcor2/appTest/bin/ttx
pex: Executing: /usr/bin/python3.10 -s -E -m compileall appTest
Traceback (most recent call last):
  File "/home/zdenal/.pex/unzipped_pexes/b1de9cb1dc137d74acdc0779598b9da266d9abcc/.bootstrap/pex/result.py", line 105, in catch
    return func(*args, **kwargs)
  File "/home/zdenal/.pex/unzipped_pexes/b1de9cb1dc137d74acdc0779598b9da266d9abcc/.bootstrap/pex/tools/commands/venv.py", line 209, in run
    pex.interpreter.execute(["-m", "compileall", venv_dir])
  File "/home/zdenal/.pex/unzipped_pexes/b1de9cb1dc137d74acdc0779598b9da266d9abcc/.bootstrap/pex/interpreter.py", line 1239, in execute
    stdout, stderr = Executor.execute(cmd, stdin_payload=stdin_payload, env=env, **kwargs)
  File "/home/zdenal/.pex/unzipped_pexes/b1de9cb1dc137d74acdc0779598b9da266d9abcc/.bootstrap/pex/executor.py", line 99, in execute
    raise cls.NonZeroExit(cmd, process.returncode, stdout, stderr)
pex.executor.Executor.NonZeroExit: received exit code 1 during execution of `['/usr/bin/python3.10', '-s', '-E', '-m', 'compileall', 'appTest']` while trying to execute `['/usr/bin/python3.10', '-s', '-E', '-m', 'compileall', 'appTest']`
received exit code 1 during execution of `['/usr/bin/python3.10', '-s', '-E', '-m', 'compileall', 'appTest']` while trying to execute `['/usr/bin/python3.10', '-s', '-E', '-m', 'compileall', 'appTest']`
...
Any idea what might be wrong? Many thanks in advance!
✅ 1
r
What pants version are you on? This is coming from PEX. I had similar issue. We had pushed the fix to some PEX version. Not sure if it has landed in the appropriate pants version. https://github.com/pantsbuild/pex/pull/2002
Or you can add the fixed pex version in the pants.toml, if you don’t want to change the pants version itself https://www.pantsbuild.org/docs/reference-pex-cli#advanced-options
Copy code
[pex-cli]
version = "v2.1.120"
known_versions = [
  "v2.1.120|macos_arm64|c8f2db310ea3e6dd400689b5993667a877d8540a4d206355fa102fff1d146ec0|4071055",
  "v2.1.120|macos_x86_64|c8f2db310ea3e6dd400689b5993667a877d8540a4d206355fa102fff1d146ec0|4071055",
  "v2.1.120|linux_x86_64|c8f2db310ea3e6dd400689b5993667a877d8540a4d206355fa102fff1d146ec0|4071055",
  "v2.1.120|linux_arm64|c8f2db310ea3e6dd400689b5993667a877d8540a4d206355fa102fff1d146ec0|4071055"
]
I copied the sha256 from this commit https://github.com/pantsbuild/pants/commit/505ab264f756e9172c56dcd23c396237efe502cb The fix actually landed in pex 2.1.119 https://github.com/pantsbuild/pex/releases/tag/v2.1.119
n
Thank you! I'm on Pants 2.14.1, and I prefer to stay on the stable version so I change the version of pex-cli and it works now. Great.
🎉 1