Subject: [bug#32538] [PATCHv2] Add emacs-elpy

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 28 Aug 2018 09:06:12 -0400

Maxim Cournoyer <[email-masked]> writes:

> Hello,
>
> This adds emacs-elpy to our collection, a worthy addition to Emacs when
> in need of editing some Python.
>
> To get the full experience, you'll want to install the following
> (optional) additions, like:
>
> guix package -i python-jedi python-autopep8 python-yapf python-black python-flake8
>
> You can enable Elpy by doing M-x elpy-mode in a Python buffer, and see
> which tools are installed using M-x elpy-config.
>
> Enjoy :)
>
> Maxim

This is a followup for the emacs-elpy package, where I added the info
and manpage documentation and fixed a couple small issues.

Thank you,

Maxim

>From dcab7ba79e9a02dcb4bf68029d072c82a49c8ee0 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:10:31 -0500
Subject: [PATCH] gnu: Add emacs-elpy.

* gnu/packages/emacs.scm (emacs-elpy): New variable.
---
 gnu/packages/emacs.scm | 77 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 797e747fb..a1c245844 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4525,6 +4525,83 @@ indentation (space indentation only).
 @end enumerate")
     (license license:gpl2+)))
 
+(define-public emacs-elpy
+  (package
+    (name "emacs-elpy")
+    (version "1.23.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jorgenschaefer/elpy.git")
+                    (commit version)))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "0dy18lyvpgr8vi2a7r13i8bn6k3b12z4l8hx0y80sh3mnakvs14n"))))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:include (cons* "^elpy/[^/]+\\.py$" "^snippets\\/" %default-include)
+       #:phases
+       ;; TODO: Make `elpy-config' display Guix commands :)
+       (modify-phases %standard-phases
+         ;; One elpy test depends on being run inside a Python virtual
+         ;; environment to pass. We have nothing to gain from doing so here,
+         ;; so we just trick Elpy into thinking we are (see:
+         ;; https://github.com/jorgenschaefer/elpy/pull/1293).
+         (add-before 'check 'fake-virtualenv
+           (lambda _
+             (setenv "VIRTUAL_ENV" "/tmp")
+             #t))
+         ;; TODO: Remove after next release (see:
+         ;; https://github.com/jorgenschaefer/elpy/pull/1293).
+         (add-after 'unpack 'fix-broken-test
+           (lambda _
+             (substitute* "test/elpy-config-test.el"
+               (("python-check-command") "elpy-syntax-check-command"))))
+         (add-before 'check 'build-doc
+           (lambda _
+             (with-directory-excursion "docs"
+               (invoke "make" "info" "man"))
+             ;; Move .info file at the root so that it can installed by the
+             ;; 'move-doc phase.
+             (rename-file "docs/_build/texinfo/Elpy.info" "Elpy.info")
+              #t))
+         (add-after 'build-doc 'install-manpage
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out  (assoc-ref outputs "out"))
+                    (man1 (string-append out "/share/man/man1")))
+               (mkdir-p man1)
+               (copy-file "docs/_build/man/elpy.1"
+                          (string-append man1 "/elpy.1")))
+             #t)))
+       #:tests? #t
+       #:test-command '("ert-runner")))
+    (propagated-inputs
+     `(("emacs-company" ,emacs-company)
+       ("emacs-find-file-in-project" ,emacs-find-file-in-project)
+       ("emacs-highlight-indentation" ,emacs-highlight-indentation)
+       ("emacs-yasnippet" ,emacs-yasnippet)
+       ("pyvenv" ,emacs-pyvenv)
+       ("s" ,emacs-s)))
+    (native-inputs
+     `(("ert-runner" ,ert-runner)
+       ("emacs-f" ,emacs-f)
+       ("python" ,python-wrapper)
+       ("python-autopep8" ,python-autopep8)
+       ("python-black" ,python-black)
+       ("python-flake8" ,python-flake8)
+       ("python-jedi" ,python-jedi)
+       ("python-yapf" ,python-yapf)
+       ;; For documentation.
+       ("python-sphinx" ,python-sphinx)
+       ("texinfo" ,texinfo)))
+    (home-page "https://github.com/jorgenschaefer/elpy")
+    (synopsis "Python development environment for Emacs")
+    (description "Elpy brings powerful Python editing to Emacs.  It combines
+and configures a number of other packages written in Emacs Lisp as well
+as Python.")
+    (license license:gpl3+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0