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

Fix wheel installs: account for purelib & platlib. #1867

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Jul 26, 2022

This fixes a further corner-case detecting --prefix installation
site-packages directories surfaced by Red Hat based OSes where
"purelib" and "platlib" installation directories differ (lib/ vs.
lib64/). We now simply check each site-packages directory found
under the installation --prefix for an installation RECORD and use
the first such one found. This is safe since we know
pip install --no-deps --prefix <dist> only installs one distribution
once.

Fixes #1866

@jsirois
Copy link
Member Author

jsirois commented Jul 26, 2022

I manually tested this on ubuntu:20.04 and centos:7 images. They both worked, but the interesting case was CentOS:

$ tox -epackage
$ docker run --rm -it -v $PWD/dist:/dist centos:7
...
[root@1d8919788a1a /]# python3 /dist/pex PyYAML ansicolors -- -c 'import yaml; print(yaml.__file__); import colors; print(colors.__file__)'
/root/.pex/installed_wheels/98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl/yaml/__init__.py
/root/.pex/installed_wheels/00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187/ansicolors-1.1.8-py2.py3-none-any.whl/colors/__init__.py
[root@1d8919788a1a /]# ls -l /root/.pex/installed_wheels/98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl/.prefix/lib64/pythonX.Y/
total 0
[root@1d8919788a1a /]# ls -l /root/.pex/installed_wheels/00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187/ansicolors-1.1.8-py2.py3-none-any.whl/.prefix/lib/pythonX.Y/
total 0

Note that PyYAML was originally installed under .prefix/lib64/pythonX.Y/site-packages whereas ansicolors was under .prefix/lib/pythonX.Y/site-packages and Pex dealt with that variance correctly.

@jsirois jsirois requested review from Eric-Arellano and benjyw July 26, 2022 06:04
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intricate. Thanks for the great comment

@jsirois
Copy link
Member Author

jsirois commented Jul 26, 2022

Lovely, this doesn't work on Mac: https://github.com/pantsbuild/pex/runs/7520701726?check_suite_focus=true#step:7:1857

I'll need to trim down CI and start debugging.

This fixes a further corner-case detecting `--prefix` installation
`site-packages` directories surfaced by Red Hat based OSes where
"purelib" and "platlib" installation directories differ (`lib/` vs.
`lib64/`). We now simply check each `site-packages` directory found
under the installation `--prefix` for an installation `RECORD` and use
the first such one found. This is safe since we know `pip install
--no-deps --prefix <dist>` only installs one distribution once.

Fixes pex-tool#1866
@jsirois
Copy link
Member Author

jsirois commented Jul 26, 2022

Alright, please take another look - the strategy has changed slightly.

I re-ran the docker manual checks, still good:

[root@c6e3ad5cc268 /]# python3 /dist/pex PyYAML ansicolors -- -c 'import yaml; print(yaml.__file__); import colors; print(colors.__file__)'
/root/.pex/installed_wheels/98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl/yaml/__init__.py
/root/.pex/installed_wheels/00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187/ansicolors-1.1.8-py2.py3-none-any.whl/colors/__init__.py
[root@c6e3ad5cc268 /]# tree /root/.pex/installed_wheels/98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl/.prefix/
/root/.pex/installed_wheels/98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4/PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl/.prefix/
`-- lib64
    `-- pythonX.Y

2 directories, 0 files
[root@c6e3ad5cc268 /]# tree /root/.pex/installed_wheels/00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187/ansicolors-1.1.8-py2.py3-none-any.whl/.prefix/                                                                      
/root/.pex/installed_wheels/00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187/ansicolors-1.1.8-py2.py3-none-any.whl/.prefix/
`-- lib
    `-- pythonX.Y

2 directories, 0 files
[root@c6e3ad5cc268 /]#

@jsirois jsirois merged commit a63a8fe into pex-tool:main Jul 27, 2022
@jsirois jsirois deleted the issues/1866 branch July 27, 2022 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pex 2.1.101 issue: virtualenv is not valid
2 participants