Patchwork [09/16] gnu: Add python-entrypoints.

login
register
mail settings
Submitter Ricardo Wurmus
Date Nov. 1, 2016, 12:20 p.m.
Message ID <20161101122046.751-10-ricardo.wurmus@mdc-berlin.de>
Download mbox | patch
Permalink /patch/17052/
State New
Headers show

Comments

Ricardo Wurmus - Nov. 1, 2016, 12:20 p.m.
* gnu/packages/python.scm (python-entrypoints, python2-entrypoints): New
variables.
---
 gnu/packages/python.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
Roel Janssen - Nov. 1, 2016, 4:18 p.m.
Ricardo Wurmus writes:

> * gnu/packages/python.scm (python-entrypoints, python2-entrypoints): New
> variables.
> ---
>  gnu/packages/python.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
>
> diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
> index a2d3d3c..621c4d0 100644
> --- a/gnu/packages/python.scm
> +++ b/gnu/packages/python.scm
> @@ -6719,6 +6719,61 @@ Jupyter Notebook format and Python APIs for working with notebooks.")
>  (define-public python2-bleach
>    (package-with-python2 python-bleach))
>  
> +(define-public python-entrypoints
> +  (package
> +    (name "python-entrypoints")
> +    (version "0.2.2")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://github.com/takluyver/entrypoints/archive/"
> +                           version ".tar.gz"))
> +       (file-name (string-append name "-" version ".tar.gz"))
> +       (sha256
> +        (base32
> +         "0azqlkh3j0za080lsf5crnhaxx3c93k9dpv5ihkhf5cppgw5sjz5"))))
> +    (build-system python-build-system)
> +    ;; The package does not come with a setup.py file, so we have to install
> +    ;; the file along with a custom egg-info file.
> +    (arguments
> +     `(#:tests? #f
> +       #:phases
> +       (modify-phases %standard-phases
> +         (delete 'build)
> +         (replace 'install
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (python-version ((@@ (guix build python-build-system)
> +                                         get-python-version)
> +                                     (assoc-ref inputs "python")))
> +                    (target (string-append out "/lib/python" python-version
> +                                           "/site-packages/")))
> +               (mkdir-p target)
> +               (call-with-output-file (string-append target "entrypoints.egg-info")
> +                 (lambda (port)
> +                   (format port "\
> +Metadata-Version: 1.1
> +Name: entrypoints
> +Version: ~a
> +Summary: Discover and load entry points from installed packages
> +Author: Thomas Kluyver
> +Author-email: thomas@kluyver.me.uk
> +Classifier: License :: OSI Approved :: MIT License
> +" ,version)))

I wonder if this would be nicer to do in a separate patch..

> +               (install-file "entrypoints.py" target)
> +               #t))))))
> +    (home-page "https://github.com/takluyver/entrypoints")
> +    (synopsis "Discover and load entry points from installed Python packages")
> +    (description "Entry points are a way for Python packages to advertise
> +objects with some common interface.  The most common examples are
> +@code{console_scripts} entry points, which define shell commands by
> +identifying a Python function to run.  The @code{entrypoints} module contains
> +functions to find and load entry points.")
> +    (license license:expat)))
> +
> +(define-public python2-entrypoints
> +  (package-with-python2 python-entrypoints))
> +
>  (define-public python-chardet
>    (package
>      (name "python-chardet")

LGTM!

Kind regards,
Roel Janssen
Hartmut Goebel - Nov. 2, 2016, 8:23 a.m.
Am 01.11.2016 um 13:20 schrieb Ricardo Wurmus:
> +       (modify-phases %standard-phases
> +         (delete 'build)
> +         (replace 'install
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (python-version ((@@ (guix build python-build-system)
> +                                         get-python-version)
> +                                     (assoc-ref inputs "python")))
> +                    (target (string-append out "/lib/python" python-version
> +                                           "/site-packages/")))
> +               (mkdir-p target)
> +               (call-with-output-file (string-append target "entrypoints.egg-info")
> +                 (lambda (port)
> +                   (format port "\
> +Metadata-Version: 1.1
> +Name: entrypoints
> +Version: ~a
> +Summary: Discover and load entry points from installed packages
> +Author: Thomas Kluyver
> +Author-email: thomas@kluyver.me.uk
> +Classifier: License :: OSI Approved :: MIT License
> +" ,version)))
> +               (install-file "entrypoints.py" target)
> +               #t))))))

Instread of this I recommend adding a minimal setup.py and let the
build-system do the job. This would be more future proof.
Ricardo Wurmus - Nov. 4, 2016, 4:54 p.m.
Hartmut Goebel <h.goebel@crazy-compilers.com> writes:

> Am 01.11.2016 um 13:20 schrieb Ricardo Wurmus:
>> +       (modify-phases %standard-phases
>> +         (delete 'build)
>> +         (replace 'install
>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>> +             (let* ((out (assoc-ref outputs "out"))
>> +                    (python-version ((@@ (guix build python-build-system)
>> +                                         get-python-version)
>> +                                     (assoc-ref inputs "python")))
>> +                    (target (string-append out "/lib/python" python-version
>> +                                           "/site-packages/")))
>> +               (mkdir-p target)
>> +               (call-with-output-file (string-append target "entrypoints.egg-info")
>> +                 (lambda (port)
>> +                   (format port "\
>> +Metadata-Version: 1.1
>> +Name: entrypoints
>> +Version: ~a
>> +Summary: Discover and load entry points from installed packages
>> +Author: Thomas Kluyver
>> +Author-email: thomas@kluyver.me.uk
>> +Classifier: License :: OSI Approved :: MIT License
>> +" ,version)))
>> +               (install-file "entrypoints.py" target)
>> +               #t))))))
>
> Instread of this I recommend adding a minimal setup.py and let the
> build-system do the job. This would be more future proof.

That’s a good idea.  I did this and it really simplified the patch a
lot.  Thanks!

~~ Ricardo

Patch

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index a2d3d3c..621c4d0 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -6719,6 +6719,61 @@  Jupyter Notebook format and Python APIs for working with notebooks.")
 (define-public python2-bleach
   (package-with-python2 python-bleach))
 
+(define-public python-entrypoints
+  (package
+    (name "python-entrypoints")
+    (version "0.2.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/takluyver/entrypoints/archive/"
+                           version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0azqlkh3j0za080lsf5crnhaxx3c93k9dpv5ihkhf5cppgw5sjz5"))))
+    (build-system python-build-system)
+    ;; The package does not come with a setup.py file, so we have to install
+    ;; the file along with a custom egg-info file.
+    (arguments
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'build)
+         (replace 'install
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (python-version ((@@ (guix build python-build-system)
+                                         get-python-version)
+                                     (assoc-ref inputs "python")))
+                    (target (string-append out "/lib/python" python-version
+                                           "/site-packages/")))
+               (mkdir-p target)
+               (call-with-output-file (string-append target "entrypoints.egg-info")
+                 (lambda (port)
+                   (format port "\
+Metadata-Version: 1.1
+Name: entrypoints
+Version: ~a
+Summary: Discover and load entry points from installed packages
+Author: Thomas Kluyver
+Author-email: thomas@kluyver.me.uk
+Classifier: License :: OSI Approved :: MIT License
+" ,version)))
+               (install-file "entrypoints.py" target)
+               #t))))))
+    (home-page "https://github.com/takluyver/entrypoints")
+    (synopsis "Discover and load entry points from installed Python packages")
+    (description "Entry points are a way for Python packages to advertise
+objects with some common interface.  The most common examples are
+@code{console_scripts} entry points, which define shell commands by
+identifying a Python function to run.  The @code{entrypoints} module contains
+functions to find and load entry points.")
+    (license license:expat)))
+
+(define-public python2-entrypoints
+  (package-with-python2 python-entrypoints))
+
 (define-public python-chardet
   (package
     (name "python-chardet")