unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patches to add s3cmd and python-magic
@ 2016-03-28  3:29 Chris Marusich
  2016-03-28 20:35 ` Danny Milosavljevic
  2016-03-30  8:20 ` Ludovic Courtès
  0 siblings, 2 replies; 12+ messages in thread
From: Chris Marusich @ 2016-03-28  3:29 UTC (permalink / raw)
  To: guix-devel


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

Hi,

I've packaged python-magic and s3cmd.  The former provides Python
bindings for libmagic.  It's an alternative to python-file, which is an
existing package that also provides Python bindings for libmagic.  The
latter is a command-line tool for Amazon S3 and CloudFront, which
expects python-magic (not python-file) to be available.

Please refer to the attached patches for details.  Guix lint says the
following about python-magic: "the source file name should contain the
package name".  However, I think maybe that's a bug in guix lint, since
the URI clearly contains the name "python-magic".

Just to be safe, I've tested python2-magic and python-magic, and
confirmed that module "magic" was importable from Python 2 (for the
former case) and Python 3 (for the latter case).  I've also confirmed
that python2-s3cmd installs fine and that I can use it for rudimentary
tasks, like uploading and downloading to/from S3.

I wasn't sure about a few things, so if you have feedback, I would love
to hear it:

* Do I need to provide setuptools as a native input, or will it be
  pulled in automatically?

* Does setuptools really need to be a native input, or can it be a
  regular input?  I understand that native inputs are important for
  cross-compiling, but does this apply to a language like Python which
  compiles to bytecode for a virtual machine?

* In the package definition for python2-s3cmd, should python2-magic be a
  propagated input instead of a regular input?  It seems to work as a
  normal input, so I think the answer is "no", but I understand that
  sometimes this matters for python packages.

Thank you,

-- 
Chris

[-- Attachment #1.2: 0001-gnu-add-python-magic.patch --]
[-- Type: text/x-patch, Size: 4625 bytes --]

From d0c858b6b717b837eb2eac95db2fb2f19ca4112a Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sun, 27 Mar 2016 19:10:48 -0700
Subject: [PATCH 1/2] gnu: add python-magic

* gnu/packages/python.scm (python-magic, python2-magic): New variables.
---
 gnu/packages/python.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 88aef9d..f2ef901 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -16,7 +16,7 @@
 ;;; Copyright © 2015, 2016 Erik Edrosa <erik.edrosa@gmail.com>
 ;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2015 Kyle Meyer <kyle@kyleam.com>
-;;; Copyright © 2015 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2015, 2016 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -6056,7 +6056,10 @@ Python's @code{ctypes} foreign function interface (FFI).")
                         #t))))))
     (inputs `(("file" ,file)))
     (self-native-input? #f)
-    (synopsis "Python bindings to the libmagic file type guesser")))
+    (synopsis "Python bindings to the libmagic file type guesser.  Note that
+this module and the python-magic module both provide a \"magic.py\" file;
+these two modules, which are different and were developed separately, both
+serve the same purpose: provide Python bindings for libmagic.")))
 
 (define-public python2-file
   (package-with-python2 python-file))
@@ -8490,3 +8493,63 @@ is made as zipfile like as possible.")
 
 (define-public python2-rarfile
   (package-with-python2 python-rarfile))
+
+(define-public python-magic
+  (package
+    (name "python-magic")
+    (version "0.4.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/ahupp/python-magic/archive/"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "17bgy92i7sb021f2s4mw1dcvpm6p1mi9jihridwy1pyn8mzvpjgk"))))
+    (build-system python-build-system)
+    (arguments
+     ;; The tests are unreliable, so don't run them.  The tests fail
+     ;; under Python3 because they were written for Python2 and
+     ;; contain import statements that do not work in Python3.  One of
+     ;; the tests fails under Python2 because its assertions are
+     ;; overly stringent; it relies on comparing output strings which
+     ;; are brittle and can change depending on the version of
+     ;; libmagic being used and the system on which the test is
+     ;; running.  In my case, under GuixSD 0.10.0, only one test
+     ;; failed, and it seems to have failed only because the version
+     ;; of libmagic that is packaged in Guix outputs a slightly
+     ;; different (but not wrong) string than the one that the test
+     ;; expected.
+     '(#:tests? #f
+       #:phases (modify-phases %standard-phases
+         ;; Replace a specific method call with a hard-coded
+         ;; path to the necessary libmagic.so file in the
+         ;; store.  If we don't do this, then the method call
+         ;; will fail to find the libmagic.so file, which in
+         ;; turn will cause any application using
+         ;; python-magic to fail.
+         (add-before 'build 'hard-code-path-to-libmagic
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((file (assoc-ref inputs "file")))
+               (substitute* "magic.py"
+                 (("ctypes.util.find_library\\('magic'\\)")
+                  (string-append "'" file "/lib/libmagic.so'")))
+           #t))))))
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)))
+    (inputs
+     ;; python-magic needs to be able to find libmagic.so.
+     `(("file" ,file)))
+    (home-page "https://github.com/ahupp/python-magic")
+    (synopsis "File type identification using libmagic")
+    (description
+     "This module uses ctypes to access the libmagic file type
+identification library.  It makes use of the local magic database and
+supports both textual and MIME-type output.  Note that this module and
+the python-file module both provide a \"magic.py\" file; these two
+modules, which are different and were developed separately, both serve
+the same purpose: to provide Python bindings for libmagic.")
+    (license license:expat)))
+
+(define-public python2-magic
+  (package-with-python2 python-magic))
-- 
2.7.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-gnu-add-python2-s3cmd.patch --]
[-- Type: text/x-patch, Size: 2293 bytes --]

From 07c6fdfaab24d95fb6b318f5bd820cbe342ed271 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sun, 27 Mar 2016 19:28:37 -0700
Subject: [PATCH 2/2] gnu: add python2-s3cmd

* gnu/packages/python.scm (python2-s3cmd): New variable.
---
 gnu/packages/python.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index f2ef901..73b674e 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -8553,3 +8553,41 @@ the same purpose: to provide Python bindings for libmagic.")
 
 (define-public python2-magic
   (package-with-python2 python-magic))
+
+(define-public python2-s3cmd
+  (package
+    (name "python2-s3cmd")
+    (version "1.6.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append "mirror://sourceforge/s3tools/"
+                            "s3cmd-" version ".tar.gz"))
+        (sha256
+          (base32
+            "0ki1rzhm5icvi9ry5jswi4b22yqwyj0d2wsqsgilwx6qhi7pjxa6"))))
+    (build-system python-build-system)
+    (arguments
+     ;; s3cmd is written for python2 only and contains no tests.
+     `(#:python ,python-2
+       #:tests? #f))
+    (native-inputs
+     `(("python2-setuptools" ,python2-setuptools)))
+    (inputs
+     `(("python2-dateutil" ,python2-dateutil)
+       ;; The python-file package also provides a magic.py module.
+       ;; This is an unfortunate state of affairs; however, s3cmd
+       ;; fails to install if it cannot find specifically the
+       ;; python-magic package.  Thus we include it, instead of using
+       ;; python-file.  Ironically, s3cmd sometimes works better
+       ;; without libmagic bindings at all:
+       ;; https://github.com/s3tools/s3cmd/issues/198
+       ("python2-magic" ,python2-magic)))
+    (home-page "http://s3tools.org/s3cmd")
+    (synopsis "Command line S3 Client and backup")
+    (description
+     "S3cmd lets you copy files from/to Amazon S3 (Simple Storage
+Service) using a simple to use command line client.  Supports
+rsync-like backup, GPG encryption, and more.  Also supports management
+of Amazon's CloudFront content delivery network.")
+    (license gpl2+)))
-- 
2.7.3


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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-28  3:29 Patches to add s3cmd and python-magic Chris Marusich
@ 2016-03-28 20:35 ` Danny Milosavljevic
  2016-03-29  5:37   ` Chris Marusich
  2016-03-30  8:20 ` Ludovic Courtès
  1 sibling, 1 reply; 12+ messages in thread
From: Danny Milosavljevic @ 2016-03-28 20:35 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

> * Do I need to provide setuptools as a native input, or will it be
>   pulled in automatically?

I think you need to provide it. Try removing it. Does your package still build?

> * Does setuptools really need to be a native input, or can it be a
>   regular input?  I understand that native inputs are important for
>   cross-compiling, but does this apply to a language like Python which
>   compiles to bytecode for a virtual machine?

If it's used only at build time, it's a native input. If it's used at runtime, regular input (if possible).
I don't think setuptools is running when s3cmd is running, so just have it as a native input.

As for the cross-compiling, you're right, I don't think it's important in this case. 

However, I think for documentation purposes it would still be nice to see which of the things are required only for the build (the native inputs - after all, they wouldn't work at runtime in general).

> * In the package definition for python2-s3cmd, should python2-magic be a
>   propagated input instead of a regular input?  It seems to work as a
>   normal input, so I think the answer is "no", but I understand that
>   sometimes this matters for python packages.

If it works as a regular input, that's even better, so keep it only as regular input. Unfortunately, that's very seldom.

The propagated input would mean that when you ask for package A in your profile, you'd get package A and B in your profile, for your own good.

When testing s3cmd, make sure that python2-magic is not in your profile (for example installed manually via guix package -i python2-magic).

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

* Re: Patches to add s3cmd and python-magic
  2016-03-28 20:35 ` Danny Milosavljevic
@ 2016-03-29  5:37   ` Chris Marusich
  2016-03-29  6:25     ` Chris Marusich
  2016-03-29  7:10     ` Efraim Flashner
  0 siblings, 2 replies; 12+ messages in thread
From: Chris Marusich @ 2016-03-29  5:37 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

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

Danny Milosavljevic <dannym@scratchpost.org> writes:

>> * Do I need to provide setuptools as a native input, or will it be
>>   pulled in automatically?
>
> I think you need to provide it. Try removing it. Does your package still build?

When I remove setuptools as a native input, the build for python-magic
succeeds, but fails for python2-magic.  I guess it's getting pulled in
implicitly in one case, but not the other.  Either way, I think it makes
sense to declare the dependency explicitly as a native input.

> As for the cross-compiling, you're right, I don't think it's important in this case. 
>
> However, I think for documentation purposes it would still be nice to
> see which of the things are required only for the build (the native
> inputs - after all, they wouldn't work at runtime in general).

That makes sense.  Thanks for explaining.

>> * In the package definition for python2-s3cmd, should python2-magic be a
>>   propagated input instead of a regular input?  It seems to work as a
>>   normal input, so I think the answer is "no", but I understand that
>>   sometimes this matters for python packages.
>
> If it works as a regular input, that's even better, so keep it only as regular input. Unfortunately, that's very seldom.

It works as a regular input.  It seems that it works as a regular input
because the s3cmd program is wrapped using the wrap-program procedure
From guix/build/utils.scm, which the python-build-system uses to set up
the PYTHONPATH appropriately.

> When testing s3cmd, make sure that python2-magic is not in your
> profile (for example installed manually via guix package -i
> python2-magic).

Good call.  I did this, and I can confirm that it works even when
python2-magic is not installed in my profile.

Thank you for the feedback!

-- 
Chris

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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  5:37   ` Chris Marusich
@ 2016-03-29  6:25     ` Chris Marusich
  2016-03-29  7:17       ` Efraim Flashner
                         ` (2 more replies)
  2016-03-29  7:10     ` Efraim Flashner
  1 sibling, 3 replies; 12+ messages in thread
From: Chris Marusich @ 2016-03-29  6:25 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

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

Hi,

Before the s3cmd package gets submitted, I'd like to confirm first that
it meets the Free System Distribution Guidelines for inclusion in Guix:

https://www.gnu.org/distros/free-system-distribution-guidelines.html

I wonder whether it meets those guidelines because I see language like
the following on other pages that are linked from there:

https://www.gnu.org/philosophy/words-to-avoid.html#CloudComputing
"Another meaning (which overlaps that but is not the same thing) is
Service as a Software Substitute, which denies you control over your
computing. You should never use SaaSS."

And here:

https://www.gnu.org/philosophy/who-does-that-server-really-serve.html
"With free software, we, the users, take back control of our
computing. Proprietary software still exists, but we can exclude it from
our lives and many of us have done so. However, we are now offered
another tempting way to cede control over our computing: Service as a
Software Substitute (SaaSS). For our freedom's sake, we have to reject
that too."

The purpose of s3cmd is to provide a command-line interface to Amazon S3
and CloudFront, which are services.  The only use for s3cmd is to enable
people to use those services.  With that in mind, does s3cmd meet the
guidelines for inclusion, or does it not?  I'm not sure, and I would
appreciate a second opinion.

-- 
Chris

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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  5:37   ` Chris Marusich
  2016-03-29  6:25     ` Chris Marusich
@ 2016-03-29  7:10     ` Efraim Flashner
  1 sibling, 0 replies; 12+ messages in thread
From: Efraim Flashner @ 2016-03-29  7:10 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

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

On Mon, Mar 28, 2016 at 10:37:48PM -0700, Chris Marusich wrote:
> Danny Milosavljevic <dannym@scratchpost.org> writes:
> 
> >> * Do I need to provide setuptools as a native input, or will it be
> >>   pulled in automatically?
> >
> > I think you need to provide it. Try removing it. Does your package still build?
> 
> When I remove setuptools as a native input, the build for python-magic
> succeeds, but fails for python2-magic.  I guess it's getting pulled in
> implicitly in one case, but not the other.  Either way, I think it makes
> sense to declare the dependency explicitly as a native input.
> 

Setuptools got integrated into python3 at some point, or a similar
functionality. In any event, python2- variants almost universally need
python2-setuptools for compiling.


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  6:25     ` Chris Marusich
@ 2016-03-29  7:17       ` Efraim Flashner
  2016-03-29  7:35         ` Chris Marusich
  2016-03-29 17:57       ` Leo Famulari
  2016-03-30  8:17       ` Ludovic Courtès
  2 siblings, 1 reply; 12+ messages in thread
From: Efraim Flashner @ 2016-03-29  7:17 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

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

On Mon, Mar 28, 2016 at 11:25:36PM -0700, Chris Marusich wrote:
> Hi,
> 
> Before the s3cmd package gets submitted, I'd like to confirm first that
> it meets the Free System Distribution Guidelines for inclusion in Guix:
> 
> https://www.gnu.org/distros/free-system-distribution-guidelines.html
> 
> I wonder whether it meets those guidelines because I see language like
> the following on other pages that are linked from there:
> 
> https://www.gnu.org/philosophy/words-to-avoid.html#CloudComputing
> "Another meaning (which overlaps that but is not the same thing) is
> Service as a Software Substitute, which denies you control over your
> computing. You should never use SaaSS."
> 
> And here:
> 
> https://www.gnu.org/philosophy/who-does-that-server-really-serve.html
> "With free software, we, the users, take back control of our
> computing. Proprietary software still exists, but we can exclude it from
> our lives and many of us have done so. However, we are now offered
> another tempting way to cede control over our computing: Service as a
> Software Substitute (SaaSS). For our freedom's sake, we have to reject
> that too."
> 
> The purpose of s3cmd is to provide a command-line interface to Amazon S3
> and CloudFront, which are services.  The only use for s3cmd is to enable
> people to use those services.  With that in mind, does s3cmd meet the
> guidelines for inclusion, or does it not?  I'm not sure, and I would
> appreciate a second opinion.
> 
> -- 
> Chris

S3 has become so ubiquitous that there are other providers out there who
offer S3 compatable storage (as you noted), and we have accepted other
packages that offer interaction with S3 storage.


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  7:17       ` Efraim Flashner
@ 2016-03-29  7:35         ` Chris Marusich
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Marusich @ 2016-03-29  7:35 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: guix-devel

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

Efraim Flashner <efraim@flashner.co.il> writes:

> S3 has become so ubiquitous that there are other providers out there who
> offer S3 compatable storage (as you noted), and we have accepted other
> packages that offer interaction with S3 storage.

If the Guix maintainers believe the package is suitable for inclusion, I
would be happy to see it included.  Otherwise, I will understand if it
cannot be included.

-- 
Chris

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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  6:25     ` Chris Marusich
  2016-03-29  7:17       ` Efraim Flashner
@ 2016-03-29 17:57       ` Leo Famulari
  2016-03-30  8:17       ` Ludovic Courtès
  2 siblings, 0 replies; 12+ messages in thread
From: Leo Famulari @ 2016-03-29 17:57 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

On Mon, Mar 28, 2016 at 11:25:36PM -0700, Chris Marusich wrote:
> Hi,
> 
> Before the s3cmd package gets submitted, I'd like to confirm first that
> it meets the Free System Distribution Guidelines for inclusion in Guix:

I had a similar question about pianobar, which is used with the Pandora
streaming music service. Here is the discussion on that topic:

http://lists.gnu.org/archive/html/guix-devel/2016-02/msg00399.html

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

* Re: Patches to add s3cmd and python-magic
  2016-03-29  6:25     ` Chris Marusich
  2016-03-29  7:17       ` Efraim Flashner
  2016-03-29 17:57       ` Leo Famulari
@ 2016-03-30  8:17       ` Ludovic Courtès
  2016-03-30 10:03         ` Chris Marusich
  2 siblings, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2016-03-30  8:17 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

Hi,

Chris Marusich <cmmarusich@gmail.com> skribis:

> The purpose of s3cmd is to provide a command-line interface to Amazon S3
> and CloudFront, which are services.  The only use for s3cmd is to enable
> people to use those services.  With that in mind, does s3cmd meet the
> guidelines for inclusion, or does it not?  I'm not sure, and I would
> appreciate a second opinion.

I think it does.  It’s an implementation of a protocol implemented by
Amazon and others now.

As far as words to avoid go, I would suggest double-checking the
description that we make.  Indeed, “there is no cloud, just other
people’s computers”:

  https://blogs.fsfe.org/mk/new-stickers-and-leaflets-no-cloud-and-e-mail-self-defense/

Ludo’.

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

* Re: Patches to add s3cmd and python-magic
  2016-03-28  3:29 Patches to add s3cmd and python-magic Chris Marusich
  2016-03-28 20:35 ` Danny Milosavljevic
@ 2016-03-30  8:20 ` Ludovic Courtès
  1 sibling, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2016-03-30  8:20 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

Chris Marusich <cmmarusich@gmail.com> skribis:

> +    (synopsis "Command line S3 Client and backup")

“Command-line S3 client and backup tool”?

> +    (description
> +     "S3cmd lets you copy files from/to Amazon S3 (Simple Storage
> +Service) using a simple to use command line client.  Supports
> +rsync-like backup, GPG encryption, and more.  Also supports management
> +of Amazon's CloudFront content delivery network.")

Maybe s/Amazon S3/on-line services compatible with Amazon’s S3/ ?

Please add subjects: “It supports …”.  Otherwise LGTM in light of your
other message.

Thanks!

Ludo’.

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

* Re: Patches to add s3cmd and python-magic
  2016-03-30  8:17       ` Ludovic Courtès
@ 2016-03-30 10:03         ` Chris Marusich
  2016-03-30 20:58           ` Ludovic Courtès
  0 siblings, 1 reply; 12+ messages in thread
From: Chris Marusich @ 2016-03-30 10:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


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

Hi Ludo,

Thank you for the thoughtful response.  I've updated the s3cmd
description per your suggestions.  Please let me know if any additional
changes are needed.

I've also attached one more small patch which adds some information that
I felt was missing from the Manual regarding the python-build-system.
Since it's small and relevant, it seemed efficient to include it here.

-- 
Chris

[-- Attachment #1.2: 0001-gnu-Add-python-magic.patch --]
[-- Type: text/x-patch, Size: 4626 bytes --]

From dfdaa5de44cf713bda0a5d907cbcc3ee986aa3f5 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sun, 27 Mar 2016 19:10:48 -0700
Subject: [PATCH 1/3] gnu: Add python-magic.

* gnu/packages/python.scm (python-magic, python2-magic): New variables.
---
 gnu/packages/python.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 88aef9d..f2ef901 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -16,7 +16,7 @@
 ;;; Copyright © 2015, 2016 Erik Edrosa <erik.edrosa@gmail.com>
 ;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2015 Kyle Meyer <kyle@kyleam.com>
-;;; Copyright © 2015 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2015, 2016 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -6056,7 +6056,10 @@ Python's @code{ctypes} foreign function interface (FFI).")
                         #t))))))
     (inputs `(("file" ,file)))
     (self-native-input? #f)
-    (synopsis "Python bindings to the libmagic file type guesser")))
+    (synopsis "Python bindings to the libmagic file type guesser.  Note that
+this module and the python-magic module both provide a \"magic.py\" file;
+these two modules, which are different and were developed separately, both
+serve the same purpose: provide Python bindings for libmagic.")))
 
 (define-public python2-file
   (package-with-python2 python-file))
@@ -8490,3 +8493,63 @@ is made as zipfile like as possible.")
 
 (define-public python2-rarfile
   (package-with-python2 python-rarfile))
+
+(define-public python-magic
+  (package
+    (name "python-magic")
+    (version "0.4.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/ahupp/python-magic/archive/"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "17bgy92i7sb021f2s4mw1dcvpm6p1mi9jihridwy1pyn8mzvpjgk"))))
+    (build-system python-build-system)
+    (arguments
+     ;; The tests are unreliable, so don't run them.  The tests fail
+     ;; under Python3 because they were written for Python2 and
+     ;; contain import statements that do not work in Python3.  One of
+     ;; the tests fails under Python2 because its assertions are
+     ;; overly stringent; it relies on comparing output strings which
+     ;; are brittle and can change depending on the version of
+     ;; libmagic being used and the system on which the test is
+     ;; running.  In my case, under GuixSD 0.10.0, only one test
+     ;; failed, and it seems to have failed only because the version
+     ;; of libmagic that is packaged in Guix outputs a slightly
+     ;; different (but not wrong) string than the one that the test
+     ;; expected.
+     '(#:tests? #f
+       #:phases (modify-phases %standard-phases
+         ;; Replace a specific method call with a hard-coded
+         ;; path to the necessary libmagic.so file in the
+         ;; store.  If we don't do this, then the method call
+         ;; will fail to find the libmagic.so file, which in
+         ;; turn will cause any application using
+         ;; python-magic to fail.
+         (add-before 'build 'hard-code-path-to-libmagic
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((file (assoc-ref inputs "file")))
+               (substitute* "magic.py"
+                 (("ctypes.util.find_library\\('magic'\\)")
+                  (string-append "'" file "/lib/libmagic.so'")))
+           #t))))))
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)))
+    (inputs
+     ;; python-magic needs to be able to find libmagic.so.
+     `(("file" ,file)))
+    (home-page "https://github.com/ahupp/python-magic")
+    (synopsis "File type identification using libmagic")
+    (description
+     "This module uses ctypes to access the libmagic file type
+identification library.  It makes use of the local magic database and
+supports both textual and MIME-type output.  Note that this module and
+the python-file module both provide a \"magic.py\" file; these two
+modules, which are different and were developed separately, both serve
+the same purpose: to provide Python bindings for libmagic.")
+    (license license:expat)))
+
+(define-public python2-magic
+  (package-with-python2 python-magic))
-- 
2.7.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-gnu-Add-python2-s3cmd.patch --]
[-- Type: text/x-patch, Size: 2400 bytes --]

From 9414eb426187e7b54332c63f6f674c2d0c233352 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sun, 27 Mar 2016 19:28:37 -0700
Subject: [PATCH 2/3] gnu: Add python2-s3cmd.

* gnu/packages/python.scm (python2-s3cmd): New variable.
---
 gnu/packages/python.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index f2ef901..4e7a3fe 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -8553,3 +8553,42 @@ the same purpose: to provide Python bindings for libmagic.")
 
 (define-public python2-magic
   (package-with-python2 python-magic))
+
+(define-public python2-s3cmd
+  (package
+    (name "python2-s3cmd")
+    (version "1.6.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append "mirror://sourceforge/s3tools/"
+                            "s3cmd-" version ".tar.gz"))
+        (sha256
+          (base32
+            "0ki1rzhm5icvi9ry5jswi4b22yqwyj0d2wsqsgilwx6qhi7pjxa6"))))
+    (build-system python-build-system)
+    (arguments
+     ;; s3cmd is written for python2 only and contains no tests.
+     `(#:python ,python-2
+       #:tests? #f))
+    (native-inputs
+     `(("python2-setuptools" ,python2-setuptools)))
+    (inputs
+     `(("python2-dateutil" ,python2-dateutil)
+       ;; The python-file package also provides a magic.py module.
+       ;; This is an unfortunate state of affairs; however, s3cmd
+       ;; fails to install if it cannot find specifically the
+       ;; python-magic package.  Thus we include it, instead of using
+       ;; python-file.  Ironically, s3cmd sometimes works better
+       ;; without libmagic bindings at all:
+       ;; https://github.com/s3tools/s3cmd/issues/198
+       ("python2-magic" ,python2-magic)))
+    (home-page "http://s3tools.org/s3cmd")
+    (synopsis "Command line tool for S3-compatible storage services")
+    (description
+     "S3cmd is a command line tool for uploading, retrieving and managing data
+in storage services that are compatible with the Amazon Simple Storage
+Service (S3) protocol, including S3 itself.  It supports rsync-like backup,
+GnuPG encryption, and more.  It also supports management of Amazon's
+CloudFront content delivery network.")
+    (license gpl2+)))
-- 
2.7.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: 0003-doc-Clarify-how-to-use-the-python-parameter.patch --]
[-- Type: text/x-patch, Size: 1382 bytes --]

From d28dcefc22c9d7a296b2b949cc8cb81ac3e9b2b0 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Wed, 30 Mar 2016 02:43:16 -0700
Subject: [PATCH 3/3] doc: Clarify how to use the '#:python' parameter.

doc/guix.texi (Build Systems): Clearly distinguish between the package that
provides the Python interpreter for the build and the package that is to be
built.  Also, mention why one might want to use a specific Python version.
---
 doc/guix.texi | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1a7f188..7a27ab3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2854,8 +2854,11 @@ For packages that install stand-alone Python programs under @code{bin/},
 it takes care of wrapping these programs so that their @code{PYTHONPATH}
 environment variable points to all the Python libraries they depend on.
 
-Which Python package is used can be specified with the @code{#:python}
-parameter.
+Which Python package is used to perform the build can be specified with
+the @code{#:python} parameter.  This is a useful way to force a package
+to be built for a specific version of the Python interpreter, which
+might be necessary if the package is only compatible with a single
+interpreter version.
 @end defvr
 
 @defvr {Scheme Variable} perl-build-system
-- 
2.7.3


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

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

* Re: Patches to add s3cmd and python-magic
  2016-03-30 10:03         ` Chris Marusich
@ 2016-03-30 20:58           ` Ludovic Courtès
  0 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2016-03-30 20:58 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

Chris Marusich <cmmarusich@gmail.com> skribis:

> From dfdaa5de44cf713bda0a5d907cbcc3ee986aa3f5 Mon Sep 17 00:00:00 2001
> From: Chris Marusich <cmmarusich@gmail.com>
> Date: Sun, 27 Mar 2016 19:10:48 -0700
> Subject: [PATCH 1/3] gnu: Add python-magic.
>
> * gnu/packages/python.scm (python-magic, python2-magic): New variables.

Applied.  I’ve added a ‘file-name’ field to the origin as suggested by
‘guix lint’.

> From 9414eb426187e7b54332c63f6f674c2d0c233352 Mon Sep 17 00:00:00 2001
> From: Chris Marusich <cmmarusich@gmail.com>
> Date: Sun, 27 Mar 2016 19:28:37 -0700
> Subject: [PATCH 2/3] gnu: Add python2-s3cmd.
>
> * gnu/packages/python.scm (python2-s3cmd): New variable.

Applied.

> From d28dcefc22c9d7a296b2b949cc8cb81ac3e9b2b0 Mon Sep 17 00:00:00 2001
> From: Chris Marusich <cmmarusich@gmail.com>
> Date: Wed, 30 Mar 2016 02:43:16 -0700
> Subject: [PATCH 3/3] doc: Clarify how to use the '#:python' parameter.
>
> doc/guix.texi (Build Systems): Clearly distinguish between the package that
> provides the Python interpreter for the build and the package that is to be
> built.  Also, mention why one might want to use a specific Python version.

Good idea, applied!  (With a “*” before the file name above. ;-))

Thank you!

Ludo’.

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

end of thread, other threads:[~2016-03-30 20:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-28  3:29 Patches to add s3cmd and python-magic Chris Marusich
2016-03-28 20:35 ` Danny Milosavljevic
2016-03-29  5:37   ` Chris Marusich
2016-03-29  6:25     ` Chris Marusich
2016-03-29  7:17       ` Efraim Flashner
2016-03-29  7:35         ` Chris Marusich
2016-03-29 17:57       ` Leo Famulari
2016-03-30  8:17       ` Ludovic Courtès
2016-03-30 10:03         ` Chris Marusich
2016-03-30 20:58           ` Ludovic Courtès
2016-03-29  7:10     ` Efraim Flashner
2016-03-30  8:20 ` Ludovic Courtès

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