* [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions.
@ 2014-12-14 19:39 Federico Beffa
2014-12-14 20:28 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Federico Beffa @ 2014-12-14 19:39 UTC (permalink / raw)
To: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 79 bytes --]
A patch to avoid python setuptools easy-install.pth collisions.
Regards,
Fede
[-- Attachment #2: 0001-build-python-build-system-Fix-easy-install.pth-colli.patch --]
[-- Type: text/x-patch, Size: 2153 bytes --]
From e63ee558fe702d429e2365b4757ddce029dc75ed Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Sat, 13 Dec 2014 22:19:08 +0100
Subject: [PATCH 1/4] build/python-build-system: Fix easy-install.pth
collisions.
* guix/build/python-build-system.scm (fix-pth): New fix-pth phase.
---
guix/build/python-build-system.scm | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 2f3d04a..44f2639 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -105,19 +105,33 @@
files)))
bindirs)))
+(define* (fix-pth #:key name inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (python (assoc-ref inputs "python"))
+ (site-packages (string-append out "/lib/python"
+ (get-python-version python)
+ "/site-packages"))
+ (easy-install-pth (string-append site-packages "/easy-install.pth"))
+ (new-pth (string-append site-packages "/" name ".pth")))
+ (if (file-exists? easy-install-pth)
+ (rename-file easy-install-pth new-pth))))
+
(define %standard-phases
;; 'configure' and 'build' phases are not needed. Everything is done during
;; 'install'.
- (alist-cons-after
- 'install 'wrap
- wrap
- (alist-replace
- 'build build
+ (alist-cons-before
+ 'strip 'fix-pth
+ fix-pth
+ (alist-cons-after
+ 'install 'wrap
+ wrap
(alist-replace
- 'check check
- (alist-replace 'install install
- (alist-delete 'configure
- gnu:%standard-phases))))))
+ 'build build
+ (alist-replace
+ 'check check
+ (alist-replace 'install install
+ (alist-delete 'configure
+ gnu:%standard-phases)))))))
(define* (python-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions.
2014-12-14 19:39 [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions Federico Beffa
@ 2014-12-14 20:28 ` Ludovic Courtès
2014-12-15 20:36 ` Federico Beffa
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2014-12-14 20:28 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> From e63ee558fe702d429e2365b4757ddce029dc75ed Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Sat, 13 Dec 2014 22:19:08 +0100
> Subject: [PATCH 1/4] build/python-build-system: Fix easy-install.pth
> collisions.
>
> * guix/build/python-build-system.scm (fix-pth): New fix-pth phase.
A good idea.
> +(define* (fix-pth #:key name inputs outputs #:allow-other-keys)
What about calling it ‘rename-pth-file’, which should be more
descriptive? Also please add a docstring.
> + (let* ((out (assoc-ref outputs "out"))
> + (python (assoc-ref inputs "python"))
> + (site-packages (string-append out "/lib/python"
> + (get-python-version python)
> + "/site-packages"))
> + (easy-install-pth (string-append site-packages "/easy-install.pth"))
> + (new-pth (string-append site-packages "/" name ".pth")))
> + (if (file-exists? easy-install-pth)
> + (rename-file easy-install-pth new-pth))))
Please use ‘when’ instead of ‘if’, and add a trailing #t, to make it
clear that the phase succeeds.
Is PACKAGE.pth a common convention? I mean, does Python (or
setuptools?) actually use files called PYTHON.pth?
Thanks for working on it!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions.
2014-12-14 20:28 ` Ludovic Courtès
@ 2014-12-15 20:36 ` Federico Beffa
2014-12-15 21:24 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Federico Beffa @ 2014-12-15 20:36 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]
On Sun, Dec 14, 2014 at 9:28 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> +(define* (fix-pth #:key name inputs outputs #:allow-other-keys)
>
> What about calling it ‘rename-pth-file’, which should be more
> descriptive? Also please add a docstring.
Agreed.
>> + (let* ((out (assoc-ref outputs "out"))
>> + (python (assoc-ref inputs "python"))
>> + (site-packages (string-append out "/lib/python"
>> + (get-python-version python)
>> + "/site-packages"))
>> + (easy-install-pth (string-append site-packages "/easy-install.pth"))
>> + (new-pth (string-append site-packages "/" name ".pth")))
>> + (if (file-exists? easy-install-pth)
>> + (rename-file easy-install-pth new-pth))))
>
> Please use ‘when’ instead of ‘if’, and add a trailing #t, to make it
> clear that the phase succeeds.
OK
> Is PACKAGE.pth a common convention? I mean, does Python (or
> setuptools?) actually use files called PYTHON.pth?
Yes, the basename of path configuration files with extension .pth does
not matter. The site module will load them all. Setuptools, on top of
easy-install.pth, installs a site.py file. This program adds (with
site.addsitedir) all directories in PYTHONPATH to the list of
directories to be processed by the site module.
https://docs.python.org/2/library/site.html
Before writing the path I had conflicts, e.g., between matplotlib and
cairocffi resulting in import failures. After the patch they work
nicely together.
Using NAME.pth instead of easy-install.pth should guarantee that no
package configuration file collisions occurs between different
packages installed with setuptools, nor between two versions of the
same library.
Attached the amended patch.
Regards,
Fede
[-- Attachment #2: 0001-build-python-build-system-Fix-easy-install.pth-colli.patch --]
[-- Type: text/x-patch, Size: 2338 bytes --]
From d32c6b5b51c4d61a2aef7467705073dafc1087d5 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Sat, 13 Dec 2014 22:19:08 +0100
Subject: [PATCH 1/4] build/python-build-system: Fix easy-install.pth
collisions.
* guix/build/python-build-system.scm (rename-pth-file): New rename-pth-file
phase and corresponding function.
---
guix/build/python-build-system.scm | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 2f3d04a..74ba0c7 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -105,19 +105,36 @@
files)))
bindirs)))
+(define* (rename-pth-file #:key name inputs outputs #:allow-other-keys)
+ "Rename easy-install.pth to NAME.pth to avoid conflicts between packages
+installed with setuptools."
+ (let* ((out (assoc-ref outputs "out"))
+ (python (assoc-ref inputs "python"))
+ (site-packages (string-append out "/lib/python"
+ (get-python-version python)
+ "/site-packages"))
+ (easy-install-pth (string-append site-packages "/easy-install.pth"))
+ (new-pth (string-append site-packages "/" name ".pth")))
+ (when (file-exists? easy-install-pth)
+ (rename-file easy-install-pth new-pth))
+ #t))
+
(define %standard-phases
;; 'configure' and 'build' phases are not needed. Everything is done during
;; 'install'.
- (alist-cons-after
- 'install 'wrap
- wrap
- (alist-replace
- 'build build
+ (alist-cons-before
+ 'strip 'rename-pth-file
+ rename-pth-file
+ (alist-cons-after
+ 'install 'wrap
+ wrap
(alist-replace
- 'check check
- (alist-replace 'install install
- (alist-delete 'configure
- gnu:%standard-phases))))))
+ 'build build
+ (alist-replace
+ 'check check
+ (alist-replace 'install install
+ (alist-delete 'configure
+ gnu:%standard-phases)))))))
(define* (python-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions.
2014-12-15 20:36 ` Federico Beffa
@ 2014-12-15 21:24 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2014-12-15 21:24 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> On Sun, Dec 14, 2014 at 9:28 PM, Ludovic Courtès <ludo@gnu.org> wrote:
[...]
>> Is PACKAGE.pth a common convention? I mean, does Python (or
>> setuptools?) actually use files called PYTHON.pth?
>
> Yes, the basename of path configuration files with extension .pth does
> not matter. The site module will load them all. Setuptools, on top of
> easy-install.pth, installs a site.py file. This program adds (with
> site.addsitedir) all directories in PYTHONPATH to the list of
> directories to be processed by the site module.
>
> https://docs.python.org/2/library/site.html
>
> Before writing the path I had conflicts, e.g., between matplotlib and
> cairocffi resulting in import failures. After the patch they work
> nicely together.
>
> Using NAME.pth instead of easy-install.pth should guarantee that no
> package configuration file collisions occurs between different
> packages installed with setuptools, nor between two versions of the
> same library.
OK, thanks for the explanation.
> From d32c6b5b51c4d61a2aef7467705073dafc1087d5 Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Sat, 13 Dec 2014 22:19:08 +0100
> Subject: [PATCH 1/4] build/python-build-system: Fix easy-install.pth
> collisions.
>
> * guix/build/python-build-system.scm (rename-pth-file): New rename-pth-file
> phase and corresponding function.
Perfect, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-15 21:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-14 19:39 [PATCH 1/4] build/python-build-system: Fix easy-install.pth collisions Federico Beffa
2014-12-14 20:28 ` Ludovic Courtès
2014-12-15 20:36 ` Federico Beffa
2014-12-15 21:24 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.