From 2649b6603ab4d44a0b1bf5d08108fc0b81ab0fc3 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen <rasmuswl@github.com> Date: Fri, 13 Jan 2023 11:23:43 +0100 Subject: [PATCH] python-setup: Fix site-packages selection without pip for Windows --- python-setup/find_site_packages.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python-setup/find_site_packages.py b/python-setup/find_site_packages.py index 8be77eb1b..5be6bc6ce 100644 --- a/python-setup/find_site_packages.py +++ b/python-setup/find_site_packages.py @@ -19,11 +19,12 @@ # poetry/requests-3, I was not allowed to install pip! So I did not pursue this # option further. # - # Instead, local testing shows that first entry of `site.getsitepackages()` has the - # right path, whereas `site.getusersitepackages()` is about the system python (very + # Instead, testing (on both Windows and Linux) shows that the last entry of + # `site.getsitepackages()` has the right path (note: On linux there is only a single + # entry), whereas `site.getusersitepackages()` is about the system python (very # confusing). # # We can't use the environment variable POETRY_VIRTUALENVS_OPTIONS_NO_PIP because it # does not work, see https://github.com/python-poetry/poetry/issues/5906 import site - print(site.getsitepackages()[0]) + print(site.getsitepackages()[-1])