From mboxrd@z Thu Jan 1 00:00:00 1970 From: Caleb Ristvedt Subject: hard-coded /gnu/store patches cause test-env to not work properly Date: Tue, 08 Jan 2019 01:44:53 -0600 Message-ID: <87tvijfv9m.fsf@cune.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:45068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggm4N-0007rP-F4 for guix-devel@gnu.org; Tue, 08 Jan 2019 02:45:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggm4M-0006Ex-EJ for guix-devel@gnu.org; Tue, 08 Jan 2019 02:45:03 -0500 Received: from mail-yw1-xc43.google.com ([2607:f8b0:4864:20::c43]:40119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggm4L-00065Z-TB for guix-devel@gnu.org; Tue, 08 Jan 2019 02:45:02 -0500 Received: by mail-yw1-xc43.google.com with SMTP id g194so1186825ywe.7 for ; Mon, 07 Jan 2019 23:44:58 -0800 (PST) Received: from GuixPotato ([208.89.170.250]) by smtp.gmail.com with ESMTPSA id z186sm36423839ywd.107.2019.01.07.23.44.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 23:44:57 -0800 (PST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Well, I finally (it only took 4 days!) found out what was causing python2-flake8@3.5.0 to fail to build only in the test environment: python-2.7-site-prefixes.patch =2D--------------------------------------- Add all /gnu/store/ prefixes found in PYTHONPATH to the prefixes where site-packages (and .pth files) are searched. *** Python-2.7.11/Lib/site.py.orig 2016-10-17 23:27:23.746149690 +0200 =2D-- Python-2.7.11/Lib/site.py 2016-10-17 23:44:51.930871644 +0200 *************** *** 65,70 **** =2D-- 65,82 ---- =20=20 # Prefixes for site-packages; add additional prefixes like /usr/local here PREFIXES =3D [sys.prefix, sys.exec_prefix] + # Guix: Add all /gnu/store-paths in PYTHONPATH--these are all + # "prefixes". This is required to search .pth files in all python + # packages contained in /gnu/store which is required to make + # .pth-defined namespace packages work. + # This is necessary if the packages are not merged into a single + # `site-packages` directory (like when using `guix environment`) but + # listed in PYTHONPATH (like when running `guix build`). + for p in sys.path: + if p.startswith('/gnu/store/'): + PREFIXES.append(p[:p.find('/', 44)]) # find first pathsep after h= ash + del p +=20 # Enable per user site-packages directory # set it to False to disable the feature or True to force the feature ENABLE_USER_SITE =3D None =2D--------------------------------------- Of course, /home/reepca/Programming/guix/test-tmp/store/ wouldn't be recognized. I manually modified the patch and re-attempted building flake8 with the new python2 and sure enough, it succeeded. Perhaps more practically, this is also an issue for anyone who installed guix with their store in a non-standard location. Are we currently assuming that anyone installing in a non-/gnu/store location is going to have NIX_STORE set? If so, the solution seems pretty easy: do what the other patches involving /gnu/store do and first attempt to honor that, only falling back to /gnu/store as a default. In that case, we should also modify proot-test-fhs.patch, as it also hardcodes /gnu/store without first attempting to honor NIX_STORE. This should at least resolve the issue for test-env, since NIX_STORE is always set in test-env and you don't need to run the programs there outside of test-env in order to test building (the main purpose). If we aren't assuming NIX_STORE is set for non-/gnu/store installs, then I guess we'd have to start generating patches based on the configured storedir. But I get the feeling it's not much of a concern. Attached is a patch that fixes python-2.7-site-prefixes.patch. --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEdNapMPRLm4SepVYGwWaqSV9/GJwFAlw0VPUACgkQwWaqSV9/ GJwehgf+LYoLgRoxgq58WB4n+nyty4PD1ybasAE383Fr/fABX2Q1OJkZQS+Ze7HW AoGPOLxVNy3pvTCvAjPMUJgijcB58yM9d8L0JgDHgQiUQi9qWh6cqUONp3/GaUOD 687AjiQKQBFQGuaO+sDN9KjD+BEHCD57FacBzXM49et/SFQbGSpcArDIqT4ytbgx 1w/hf4pECih6yvhSNW5edFUYVUiZzqqWX4309fSNw2hmsPk+n29Wx3/WQzJPQEyA blLuamSSbZaF9hqhUC2cJ/1Hfg7o1Kzy9GAWr6dcX3V3q5Alz1aJVBARIdimm2M5 1n2fMY974aC3oowjr/XkUhs6LzJt6Q== =7Nuk -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-patches-honor-NIX_STORE-in-site.py.patch Content-Description: site-prefixes patch >From e9fdaec83568d14b5462757b473ed6f25b3f114e Mon Sep 17 00:00:00 2001 From: Caleb Ristvedt Date: Tue, 8 Jan 2019 01:26:59 -0600 Subject: [PATCH] patches: honor NIX_STORE in site.py. Previously various python packages would fail to work unless the store they were kept in was /gnu/store. This fixes that. * gnu/packages/patches/python-2.7-site-prefixes.patch: Try NIX_STORE first and only use /gnu/store as a fallback. --- gnu/packages/patches/python-2.7-site-prefixes.patch | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gnu/packages/patches/python-2.7-site-prefixes.patch b/gnu/packages/patches/python-2.7-site-prefixes.patch index 9e3066508..0451d07f4 100644 --- a/gnu/packages/patches/python-2.7-site-prefixes.patch +++ b/gnu/packages/patches/python-2.7-site-prefixes.patch @@ -5,7 +5,7 @@ site-packages (and .pth files) are searched. --- Python-2.7.11/Lib/site.py 2016-10-17 23:44:51.930871644 +0200 *************** *** 65,70 **** ---- 65,82 ---- +--- 65,85 ---- # Prefixes for site-packages; add additional prefixes like /usr/local here PREFIXES = [sys.prefix, sys.exec_prefix] @@ -16,9 +16,12 @@ site-packages (and .pth files) are searched. + # This is necessary if the packages are not merged into a single + # `site-packages` directory (like when using `guix environment`) but + # listed in PYTHONPATH (like when running `guix build`). ++ guix_store = os.getenv("NIX_STORE") ++ if not guix_store: ++ guix_store = '/gnu/store' + for p in sys.path: -+ if p.startswith('/gnu/store/'): -+ PREFIXES.append(p[:p.find('/', 44)]) # find first pathsep after hash ++ if p.startswith(guix_store): ++ PREFIXES.append(p[:p.find('/', 34 + len(guix_store))]) # find first pathsep after hash + del p + # Enable per user site-packages directory -- 2.20.0 --=-=-=--