unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chris Marusich <cmmarusich@gmail.com>
To: Ben Woodcroft <b.woodcroft@uq.edu.au>
Cc: "guix-devel@gnu.org" <guix-devel@gnu.org>
Subject: Re: [PATCH] gnu: Add python-contextlib2
Date: Sat, 21 Nov 2015 13:28:41 -0800	[thread overview]
Message-ID: <CAEKzfHmniiQWKkFumA2FY_gSJAOKu2yaHg+_sEzNgvaFbmeBrA@mail.gmail.com> (raw)
In-Reply-To: <564C7549.3070707@uq.edu.au>

[-- Attachment #1: Type: text/plain, Size: 3462 bytes --]

Hi,

Thank you for the feedback, Ben and Andreas! I did not know about the
"modify-phases" procedure. That's very useful. I've attached the
modified patch. I've confirmed for both packages that "guix lint" does
not show any errors, that the build succeeds (and tests are run
successfully), and that installation also succeeds. It turns out that
you need to check the exit code of the system* call; if you don't, the
build will succeed even when the tests fail. So I've added that.

However, there is one curiosity. I've noticed that when I run
"./pre-inst-env guix environment python2-contextlib2", the PYTHONPATH
is configured to allow importation of contextlib2 from the
$profile/lib/python3.4/site-packages directory tree, rather than
$profile/lib/python2.7/site-packages. When I run python in this
environment, I get a Python 2.7 interpreter. When I import
contextlib2, it succeeds, and when I check the module's file location,
I see that it does in fact come from the
$profile/lib/python3.4/site-packages directory tree. This seems odd.
Is this expected behavior? Here's the exact output I see (hopefully my
email client won't mess up the formatting too badly):

[0] marusich@garuda:~/guix
$ ./pre-inst-env guix package --list-installed=context
;;; note: source file /home/marusich/guix/gnu/packages/python.scm
;;;       newer than compiled /home/marusich/guix/gnu/packages/python.go
;;; note: source file /home/marusich/guix/gnu/packages/python.scm
;;;       newer than compiled
/home/marusich/.cache/guile/ccache/2.0-LE-8-2.0/home/marusich/guix/gnu/packages/python.scm.go
python-contextlib2	0.4.0	out	/gnu/store/5k9qn3csi0w32xrjqv50f9ifyjf0bb29-python-contextlib2-0.4.0
python2-contextlib2	0.4.0	out	/gnu/store/msvhvplrir30lbdk5f54x9mxr7pm8qd5-python2-contextlib2-0.4.0
[0] marusich@garuda:~/guix
$ ls /gnu/store/msvhvplrir30lbdk5f54x9mxr7pm8qd5-python2-contextlib2-0.4.0
lib/
[0] marusich@garuda:~/guix
$ ls /gnu/store/msvhvplrir30lbdk5f54x9mxr7pm8qd5-python2-contextlib2-0.4.0/lib/python2.7/site-packages/contextlib2
contextlib2-0.4.0-py2.7.egg-info  contextlib2.py
contextlib2.pyc
[0] marusich@garuda:~/guix
$ ./pre-inst-env guix environment python2-contextlib2
;;; note: source file /home/marusich/guix/gnu/packages/python.scm
;;;       newer than compiled /home/marusich/guix/gnu/packages/python.go
;;; note: source file /home/marusich/guix/gnu/packages/python.scm
;;;       newer than compiled
/home/marusich/.cache/guile/ccache/2.0-LE-8-2.0/home/marusich/guix/gnu/packages/python.scm.go
[0] [env] marusich@garuda:~/guix
$ env | grep PYTHONP
PYTHONPATH=/gnu/store/sf69z6zr57vjgh57a1vsf7kr7bcsg5pj-python-2.7.10/lib/python2.7/site-packages:/home/marusich/.guix-profile/lib/python3.4/site-packages
[0] [env] marusich@garuda:~/guix
$ env | grep PYTHON
PYTHONPATH=/gnu/store/sf69z6zr57vjgh57a1vsf7kr7bcsg5pj-python-2.7.10/lib/python2.7/site-packages:/home/marusich/.guix-profile/lib/python3.4/site-packages
[0] [env] marusich@garuda:~/guix
$

I'm also curious: why does the "(#:phases" part need to be
quasi-quoted with the backtick symbol "`"? I know what quoting and
quasi-quoting are, but I'm not familiar with Scheme records, so it's
possible that this is something obvious that is related to records
which I just haven't learned about yet. I ask because I searched the
manual and could not find any obvious leads, so if you can point me in
the right direction to understand why the quasi-quote is necessary
here, I'd be grateful.

Thank you,
Chris

[-- Attachment #2: 0001-gnu-Add-python-contextlib2.patch --]
[-- Type: application/octet-stream, Size: 2067 bytes --]

From d7ee2fc4eb93dd170a01592ccc1473268e81806a Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Mon, 16 Nov 2015 09:28:37 -0800
Subject: [PATCH] gnu: Add python-contextlib2.

* gnu/packages/python.scm (python-contextlib2, python2-contextlib2):
  New variables.
---
 gnu/packages/python.scm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 4e54ef9..2353ab0 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2015 Eric Dvorsak <eric@dvorsak.fr>
 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2015 Ben Woodcroft <donttrustben@gmail.com>
+;;; Copyright © 2015, Chris Marusich <cmmarusich@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5895,3 +5896,31 @@ automatically detect a wide range of file encodings.")
 
 (define-public python2-chardet
   (package-with-python2 python-chardet))
+
+(define-public python-contextlib2
+  (package
+    (name "python-contextlib2")
+    (version "0.4.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "contextlib2" version))
+        (sha256
+         (base32 "0cmp131dlh0d0zvw0aza1zd13glvngzk8lb4avks0hm7yxwdr9am"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (replace 'check
+           (lambda _ (zero?
+                      (system* "python" "test_contextlib2.py", "-v")))))))
+    (home-page "http://contextlib2.readthedocs.org/")
+    (synopsis "Tools for decorators and context managers")
+    (description "This module is primarily a backport of the Python 3.2 contextlib to
+earlier Python versions.  Like contextlib, it provides utilities for common
+tasks involving decorators and context managers.  It also contains
+additional features that are not part of the standard library.")
+    (license psfl)))
+
+(define-public python2-contextlib2
+  (package-with-python2 python-contextlib2))
-- 
2.5.0


  reply	other threads:[~2015-11-21 21:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18  8:31 [PATCH] gnu: Add python-contextlib2 Chris Marusich
2015-11-18  8:46 ` Andreas Enge
2015-11-18  8:46 ` Chris Marusich
2015-11-18 12:55 ` Ben Woodcroft
2015-11-21 21:28   ` Chris Marusich [this message]
2015-11-26 13:44     ` Ludovic Courtès
2015-12-01  8:22       ` Chris Marusich
2015-12-06 21:49         ` Ludovic Courtès
2015-12-08  5:14           ` Chris Marusich
2015-12-13 23:16             ` Ludovic Courtès
2015-12-14  2:15               ` Chris Marusich
2015-12-14  8:44                 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEKzfHmniiQWKkFumA2FY_gSJAOKu2yaHg+_sEzNgvaFbmeBrA@mail.gmail.com \
    --to=cmmarusich@gmail.com \
    --cc=b.woodcroft@uq.edu.au \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).