Skip to content

site.py removal in 49.0.0 breaks eggs installed outside system prefix #2295

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

Open
ystreet opened this issue Aug 1, 2020 · 6 comments
Open

Comments

@ystreet
Copy link

ystreet commented Aug 1, 2020

site.py was removed in #2165 and first released with setuptools 49.0.0

This now causes installed eggs to not be loaded when installed to a prefix and pointed to by PYTHONPATH.

E.g. a concrete example of this use is with GStreamer's cerbero build system which installs the meson build system to a custom prefix to avoid messing up user/system installations. Relevant code for that is: https://gitlab.freedesktop.org/gstreamer/cerbero/-/blob/master/recipes/build-tools/meson.recipe#L30

PYTHONPATH is constructed by cerbero to point to the necessary path for the installed location (e.g. PYTHONPATH=/path/to/cerbero/build/build-tools/lib/python3.8/site-packages/). Without the site.py that is installed, this does not work anymore.

One can reproduce by doing the following:

git clone https://gitlab.freedesktop.org/gstreamer/cerbero.git
cd cerbero
./cerbero-uninstalled -c config/build-tools.cbc build meson
./cerbero-uninstalled shell
python3 -c "import sys; print(sys.path)"
# should output a value containing '/path/to/cerbero/build/build-tools/lib/python3.8/site-packages/meson-0.54.0-py3.8.egg'

Reverting to python-setuptools < 49.0.0 is one workaround.

@jaraco
Copy link
Member

jaraco commented Aug 16, 2020

Thanks for the report.

The usage of setup.py install (which implicitly invokes easy_install) in that project is deprecated, so it's probably best to start working out a long-term fix that doesn't involve easy_install.

I recommend that the project use pip install --prefix or possibly pip install --target to install packages and supply a sitecustomize.py (example) to ensure that directory ends up as a site dir and gets .pth processing. That approach should be future-proof (at least against the sunset of easy_install).

Please let me know if that approach sounds viable (or if not, why) and how I can help.

@ystreet
Copy link
Author

ystreet commented Aug 20, 2020

I had a go at implementing the sitecustomize.py modification you have described however it does not seem that the sitecustomize does not have any effect and is not executed at all. WIP is available from https://gitlab.freedesktop.org/ystreet/cerbero/-/commits/sitecustomize

The reproduction instructions for this version require running ./cerbero-uninstalled bootstrap instead of ./cerbero-uninstalled -c config/build-tools.cbc build meson to get the custom sitecustomize.py written to /path/to/cerbero/build/build-tools/lib/python3.8/site-packages/sitecustomize.py

./cerbero-uninstalled bootstrap # at least until things start building.  Can Ctrl-C and run the meson-specific command once things start building
./cerbero-uninstalled shell
python3 -c "import sys; print(sys.path)"
# should output a value containing '/path/to/cerbero/build/build-tools/lib/python3.8/site-packages/meson-0.54.0-py3.8.egg'

To wipe all built sources to start again:

./cerbero-uninstalled wipe --force --build-tools

For completeness, this is currently running on Arch Linux with Python 3.8.5 and python-setuptools 49.6.0

@jaraco
Copy link
Member

jaraco commented Aug 31, 2020

Could it be a typo in sitecustomize.y (note the missing 'p')?

@ystreet
Copy link
Author

ystreet commented Aug 31, 2020

Ah, silly me 🤦

Now, the paths are in the wrong order:

python3 -c "import sys; print(sys.path)" produces:
['', '/home/matt/Projects/cerbero/build/dist/linux_x86_64/lib/python3.8/site-packages', '/home/matt/Projects/cerbero/build/build-tools/lib/python3.8/site-packages', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/matt/.local/lib/python3.8/site-packages', '/usr/lib/python3.8/site-packages', '/home/matt/Projects/cerbero/build/build-tools/lib/python3.8/site-packages/meson-0.54.0-py3.8.egg']
with: PYTHONPATH=/home/matt/Projects/cerbero/build/dist/linux_x86_64/lib/python3.8/site-packages/:/home/matt/Projects/cerbero/build/build-tools/lib/python3.8/site-packages/

I need the meson path before all the default system paths otherwise a system install of meson is going to be used instead :)

@ystreet
Copy link
Author

ystreet commented Aug 31, 2020

The path ordering looks like it was taken care of within the original site.py by inserting .pth entries before the system determined paths which is actually what is needed here.

@ystreet
Copy link
Author

ystreet commented Oct 29, 2020

For now, we are going to reinstate the removed site.py until this is fixed: https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/655

rgonzalezfluendo pushed a commit to fluendo/cerbero that referenced this issue May 2, 2022
rgonzalezfluendo pushed a commit to fluendo/cerbero that referenced this issue May 25, 2022
rgonzalezfluendo pushed a commit to fluendo/cerbero that referenced this issue Aug 25, 2022
rgonzalezfluendo pushed a commit to fluendo/cerbero that referenced this issue Sep 19, 2022
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

No branches or pull requests

2 participants