<#2023 A loose layout, venv-with-symlink PEX creat...
# github-notifications
q
#2023 A loose layout, venv-with-symlink PEX creates brittle symlinks Issue created by thejcannon Pex version
2.1.113
I found this through Pants, but ultimately seems like a PEX issue/fix.
Copy code
$ pex --no-venv-copies --layout=loose --venv prepend awscli --script aws -o  awscli.pex
$ python awscli.pex help
<help output>
$ mv awscli.pex awscli2.pex/
$ python awscli2.pex
Traceback (most recent call last):
  File "/home/josh/.pex/venvs/ea7cb7998ed2db4f784178989a4034013cd10e01/ddab8011daaee380698ac2fb9701af18c90c03f6/bin/aws", line 19, in <module>
    import awscli.clidriver
ModuleNotFoundError: No module named 'awscli
See also:
Copy code
$ ls -l /home/josh/.pex/venvs/ea7cb7998ed2db4f784178989a4034013cd10e01/ddab8011daaee380698ac2fb9701af18c90c03f6/lib/python3.8/site-packages/awscli
lrwxrwxrwx 1 josh josh 107 Jan  3 11:49 /home/josh/.pex/venvs/ea7cb7998ed2db4f784178989a4034013cd10e01/ddab8011daaee380698ac2fb9701af18c90c03f6/lib/python3.8/site-packages/awscli -> ../../../../../../../../../<CWD>/awscli.pex/.deps/awscli-1.27.41-py3-none-any.whl/awscli
In Pants-land, this manifests as being a symlink to an ephemeral Pants sandbox which has since gone bye-bye. * * * What I might expect is that on first run, the wheels get copied into the PEX root and then the venv symlinks to the extracted wheels in the pex root so moving/deleting the original pex doesn't invalidate the venv. pantsbuild/pex