unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* hard-coded /gnu/store patches cause test-env to not work properly
@ 2019-01-08  7:44 Caleb Ristvedt
  2019-01-08  8:08 ` Ricardo Wurmus
  0 siblings, 1 reply; 2+ messages in thread
From: Caleb Ristvedt @ 2019-01-08  7:44 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 2661 bytes --]

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

----------------------------------------
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
--- Python-2.7.11/Lib/site.py	2016-10-17 23:44:51.930871644 +0200
***************
*** 65,70 ****
--- 65,82 ----
  
  # Prefixes for site-packages; add additional prefixes like /usr/local here
  PREFIXES = [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 hash
+ del p
+ 
  # Enable per user site-packages directory
  # set it to False to disable the feature or True to force the feature
  ENABLE_USER_SITE = None
----------------------------------------

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.


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: site-prefixes patch --]
[-- Type: text/x-patch, Size: 1861 bytes --]

From e9fdaec83568d14b5462757b473ed6f25b3f114e Mon Sep 17 00:00:00 2001
From: Caleb Ristvedt <caleb.ristvedt@cune.org>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: hard-coded /gnu/store patches cause test-env to not work properly
  2019-01-08  7:44 hard-coded /gnu/store patches cause test-env to not work properly Caleb Ristvedt
@ 2019-01-08  8:08 ` Ricardo Wurmus
  0 siblings, 0 replies; 2+ messages in thread
From: Ricardo Wurmus @ 2019-01-08  8:08 UTC (permalink / raw)
  To: Caleb Ristvedt; +Cc: guix-devel


Hi Caleb,

> 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

Ouch!

> 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.

I think this would be better.  The patch could contain the @GUIX_STORE@
placeholder, which you then patch out in a snippet.

-- 
Ricardo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-08  8:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-08  7:44 hard-coded /gnu/store patches cause test-env to not work properly Caleb Ristvedt
2019-01-08  8:08 ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).