unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/1] gnu: Add python-betamax.
@ 2016-10-16 17:17 Leo Famulari
  2016-10-16 20:22 ` Marius Bakke
  2016-10-17  8:56 ` Hartmut Goebel
  0 siblings, 2 replies; 4+ messages in thread
From: Leo Famulari @ 2016-10-16 17:17 UTC (permalink / raw)
  To: guix-devel

This is a build time dependency of python-requests-toolbelt when using
Python 3.5.

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

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 07ac017..3e3ff9e 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -11068,3 +11068,35 @@ with an associated set of resolve methods that know how to fetch data.")
 provide extendible implementations of common aspects of a cloud so that you can
 focus on building massively scalable web applications.")
     (license license:expat)))
+
+(define-public python-betamax
+  (package
+    (name "python-betamax")
+    (version "0.8.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "betamax" version))
+        (sha256
+         (base32
+          "18f8v5gng3j773jlbbzx4rg1i4y2zw3m2l1zpmbvp8bh5a2q1i42"))))
+    (build-system python-build-system)
+    (arguments
+     '(;; Many tests fail because they require networking.
+       #:tests? #f))
+    (inputs
+     `(("python-requests" ,python-requests)))
+    (home-page "https://github.com/sigmavirus24/betamax")
+    (synopsis "Record HTTP interactions with python-requests")
+    (description "Betamax will record your test suite's HTTP interactions and
+replay them during future tests.  It is designed to work with python-requests.")
+    (license license:expat)
+    (properties `((python2-variant . ,(delay python2-betamax))))))
+
+(define-public python2-betamax
+  (let ((base (package-with-python2 (strip-python2-variant python-betamax))))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("python2-setuptools" ,python2-setuptools)
+         ,@(package-native-inputs base))))))
-- 
2.10.1

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

* Re: [PATCH 1/1] gnu: Add python-betamax.
  2016-10-16 17:17 [PATCH 1/1] gnu: Add python-betamax Leo Famulari
@ 2016-10-16 20:22 ` Marius Bakke
  2016-10-17 12:03   ` Hartmut Goebel
  2016-10-17  8:56 ` Hartmut Goebel
  1 sibling, 1 reply; 4+ messages in thread
From: Marius Bakke @ 2016-10-16 20:22 UTC (permalink / raw)
  To: Leo Famulari, guix-devel

Leo Famulari <leo@famulari.name> writes:

> This is a build time dependency of python-requests-toolbelt when using
> Python 3.5.
>
> * gnu/packages/python.scm (python-betamax, python2-betamax): New variables.

This LGTM, but I have a couple of off-topic remarks.

The requests input/reference was a bit odd and seems to come from a
python PTH [0] file that sets up the full path to the requests library:

$ cat /gnu/store/q73wijsf2bapjwy47z5cl3jbq9rydmim-python-betamax-0.8.0/lib/python3.4/site-packages/python-betamax-0.8.0.pth
import sys; sys.__plen = len(sys.path)
./betamax-0.8.0-py3.4.egg
/gnu/store/4yxlmdi684axj11dxf0d905dfrjvaw3s-python-requests-2.9.1/lib/python3.4/site-packages/requests-2.9.1-py3.4.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

I can load this from a pure environment:

$ ./pre-inst-env guix environment --container --pure --ad-hoc python-betamax python
[...]
[env]# python3 -c 'import betamax'
[env]#

Doing the same when applied to wip-python-build-system results in:

[env]# python3 -c 'import betamax'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/gnu/store/gs8jwja6d5k96l32v5psvxwzvwk61rll-profile/lib/python3.4/site-packages/betamax/__init__.py", line 13, in <module>
    from .decorator import use_cassette
  File "/gnu/store/gs8jwja6d5k96l32v5psvxwzvwk61rll-profile/lib/python3.4/site-packages/betamax/decorator.py", line 4, in <module>
    import requests
ImportError: No module named 'requests'

Can we leverage this mechanism instead of propagating everything? Are
there any drawbacks to doing that?

I'll have to do some more investigation around how those .pth files are
created, but food for thought. Perhaps it only works with eggs?

0: https://docs.python.org/3/library/site.html

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

* Re: [PATCH 1/1] gnu: Add python-betamax.
  2016-10-16 17:17 [PATCH 1/1] gnu: Add python-betamax Leo Famulari
  2016-10-16 20:22 ` Marius Bakke
@ 2016-10-17  8:56 ` Hartmut Goebel
  1 sibling, 0 replies; 4+ messages in thread
From: Hartmut Goebel @ 2016-10-17  8:56 UTC (permalink / raw)
  To: guix-devel

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

Am 16.10.2016 um 19:17 schrieb Leo Famulari:
> +    (inputs
> +     `(("python-requests" ,python-requests)))

These need to be propagated inputs, In assume. Please refer to the
Python packaging guide which was updated some days ago.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |


[-- Attachment #2: 0xBF773B65.asc --]
[-- Type: application/pgp-keys, Size: 15087 bytes --]

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

* Re: [PATCH 1/1] gnu: Add python-betamax.
  2016-10-16 20:22 ` Marius Bakke
@ 2016-10-17 12:03   ` Hartmut Goebel
  0 siblings, 0 replies; 4+ messages in thread
From: Hartmut Goebel @ 2016-10-17 12:03 UTC (permalink / raw)
  To: guix-devel

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

Am 16.10.2016 um 22:22 schrieb Marius Bakke:
> Can we leverage this mechanism instead of propagating everything? Are
> there any drawbacks to doing that?

propagating all inputs is the correct way for two reasons:

a) In Python only *one* version of a module can but used within an
environment [*] So you will end up in troubles if some packages list
different (incompatible) versions of a package in a .pth file. You will
have a lot of fun debugging this. (It took me one or two hours to
understand what's going on there, and being one of the core developers
of PyInstaller I'm quite skilled regarding all these import mechanisms
in Python.)

b) guix will not be able to tack these dependencies AFAIK, see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20765


[*] One can install different version of a module, but this is rarely
used and not supported when installing via pip.

> I'll have to do some more investigation around how those .pth files are
> created, but food for thought. Perhaps it only works with eggs?

They are very archaic and work with normal module, too.
https://docs.python.org/3/library/site.html

You may want to compare the results of (I suggest using a virtual
environment for the tests):

easy_install py==1.4.31
python ./setup.py easy_install py==1.4.31
python ./setup.py install py==1.4.31
python ./setup.py install --root=/ py==1.4.31

BTW: Just today I discovered nasty problems with namespace packages
under python2. So I still need to do some recherché.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |


[-- Attachment #2: 0xBF773B65.asc --]
[-- Type: application/pgp-keys, Size: 15087 bytes --]

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

end of thread, other threads:[~2016-10-17 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-16 17:17 [PATCH 1/1] gnu: Add python-betamax Leo Famulari
2016-10-16 20:22 ` Marius Bakke
2016-10-17 12:03   ` Hartmut Goebel
2016-10-17  8:56 ` Hartmut Goebel

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