Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pex fails to layout venvs properly. #1630

Closed
jsirois opened this issue Feb 25, 2022 · 3 comments · Fixed by #1632
Closed

Pex fails to layout venvs properly. #1630

jsirois opened this issue Feb 25, 2022 · 3 comments · Fixed by #1632
Assignees
Labels

Comments

@jsirois
Copy link
Member

jsirois commented Feb 25, 2022

There is probably a bug here for unzip mode too.

For example, via Pip:

^jsirois@gill /tmp/test $ python -mvenv nbconvert.venv
^jsirois@gill /tmp/test $ source nbconvert.venv/bin/activate
(nbconvert.venv) ^jsirois@gill /tmp/test $ pip -q install -U pip
(nbconvert.venv) ^jsirois@gill /tmp/test $ pip -q install nbconvert
(nbconvert.venv) ^jsirois@gill /tmp/test $ find nbconvert.venv -type d -name share
nbconvert.venv/share
(nbconvert.venv) ^jsirois@gill /tmp/test $ grep share nbconvert.venv/lib/python3.10/site-packages/nbconvert-6.4.2.dist-info/RECORD | head
../../../share/jupyter/nbconvert/templates/asciidoc/conf.json,sha256=YtRONxl919kXwtomCBZ-CM4p-uOFDOCk9SnmFThA_Qg,87
../../../share/jupyter/nbconvert/templates/asciidoc/index.asciidoc.j2,sha256=ldvuvwVyz0b7bO2ZZ8NXcnI4cdyKJBfslWnd_xZLZKc,2298
../../../share/jupyter/nbconvert/templates/base/celltags.j2,sha256=_Gi6rqD8HQUQZgzuRRSVqDJ-J5rD0Z9lmPswq2kW6mc,213
../../../share/jupyter/nbconvert/templates/base/display_priority.j2,sha256=wEMM_359LWVzWQpz8GzYXeWkzQGA3Mqwp_pRiYCgUhw,1442
../../../share/jupyter/nbconvert/templates/base/jupyter_widgets.html.j2,sha256=3vEiL0FN_Nni6SCNlj-jLpukRyPGRY2NUzj-JgJhBFs,1256
../../../share/jupyter/nbconvert/templates/base/mathjax.html.j2,sha256=vmg4jv_ICDmQbQiN40X4V_GIfDlxNTusgfG2Qv6HpB0,1198
../../../share/jupyter/nbconvert/templates/base/null.j2,sha256=Fw8IIQZnAa6RcI30Vjy6YPDLkFX44glRQTTjEc-PfrI,6229
../../../share/jupyter/nbconvert/templates/basic/conf.json,sha256=74s0_-_38TnwNLy8xIjys_J_acbOEGRu8DKNUftxMHk,87
../../../share/jupyter/nbconvert/templates/basic/index.html.j2,sha256=ovChqOqeUNBJMBSvRCDPBvF6wJVhDPPF5ly3Y-qPs6g,39
../../../share/jupyter/nbconvert/templates/classic/base.html.j2,sha256=w01A7PQw2sLpKCl1tycqhAHl9NTTYir9W9Myi-hZZ6Y,7499

But via Pex:

^jsirois@gill /tmp/test $ pex nbconvert --venv -o nbconvert.pex
^jsirois@gill /tmp/test $ PEX_TOOLS=1 ./nbconvert.pex venv nbconvert.pex.venv
^jsirois@gill /tmp/test $ find nbconvert.pex.venv -type d -name share
nbconvert.pex.venv/lib/python3.10/site-packages/share

So Pex is failing to read the RECORD to determine final relative resting paths in the venv. It currently special-cases bin with this code instead of using the RECORD so gets away with the vast majority of use cases, but not all!:
https://github.com/pantsbuild/pex/blob/f931befd5ed96d343f2182f34c403bc8bfb188fe/pex/tools/commands/venv.py#L191-L196

@jsirois jsirois added the bug label Feb 25, 2022
@jsirois
Copy link
Member Author

jsirois commented Feb 25, 2022

In the PEX case, the RECORD is different with - apparently - one too few ..:

$ grep share nbconvert.pex.venv/lib/python3.10/site-packages/nbconvert-6.4.2.dist-info/RECORD | head
../../share/jupyter/nbconvert/templates/asciidoc/conf.json,sha256=YtRONxl919kXwtomCBZ-CM4p-uOFDOCk9SnmFThA_Qg,87
../../share/jupyter/nbconvert/templates/asciidoc/index.asciidoc.j2,sha256=ldvuvwVyz0b7bO2ZZ8NXcnI4cdyKJBfslWnd_xZLZKc,2298
../../share/jupyter/nbconvert/templates/base/celltags.j2,sha256=_Gi6rqD8HQUQZgzuRRSVqDJ-J5rD0Z9lmPswq2kW6mc,213
../../share/jupyter/nbconvert/templates/base/display_priority.j2,sha256=wEMM_359LWVzWQpz8GzYXeWkzQGA3Mqwp_pRiYCgUhw,1442
../../share/jupyter/nbconvert/templates/base/jupyter_widgets.html.j2,sha256=3vEiL0FN_Nni6SCNlj-jLpukRyPGRY2NUzj-JgJhBFs,1256
../../share/jupyter/nbconvert/templates/base/mathjax.html.j2,sha256=vmg4jv_ICDmQbQiN40X4V_GIfDlxNTusgfG2Qv6HpB0,1198
../../share/jupyter/nbconvert/templates/base/null.j2,sha256=Fw8IIQZnAa6RcI30Vjy6YPDLkFX44glRQTTjEc-PfrI,6229
../../share/jupyter/nbconvert/templates/basic/conf.json,sha256=74s0_-_38TnwNLy8xIjys_J_acbOEGRu8DKNUftxMHk,87
../../share/jupyter/nbconvert/templates/basic/index.html.j2,sha256=ovChqOqeUNBJMBSvRCDPBvF6wJVhDPPF5ly3Y-qPs6g,39
../../share/jupyter/nbconvert/templates/classic/base.html.j2,sha256=w01A7PQw2sLpKCl1tycqhAHl9NTTYir9W9Myi-hZZ6Y,7499

Pex will need to adjust for that assuming that's a consistent result.

@jsirois jsirois self-assigned this Feb 25, 2022
@jsirois
Copy link
Member Author

jsirois commented Feb 26, 2022

The RECORD being different / wrong for --target mode, which Pex uses, is known: pypa/pip#7658

The --prefix mode records a valid RECORD so maybe Pex wheel install chroots should use this scheme and adjustments be made to the runtime.

@jsirois
Copy link
Member Author

jsirois commented Feb 27, 2022

As usual, the variety present in the PyPA ecosystem made this interesting.

jsirois added a commit that referenced this issue Feb 28, 2022
This uses the RECORD as the basis for determining which files to copy
and where they belong, fixing the issues with data files not being
properly located.

Fixes #1630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant