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

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 05 Sep 2018 08:00:13 -0400

Hello Ludovic!

[email-masked] (Ludovic Courtès) writes:

> Hello Maxim,
>
> I didn’t actually try the patch set but on a quick look it LGTM!
> (Including v2 of the emacs-elpy patch itself.)
>
> Maxim Cournoyer <[email-masked]> skribis:
>
>> From 54130c8f5bcf683b1681e1a6c6238421bd0c6459 Mon Sep 17 00:00:00 2001
>> From: Maxim Cournoyer <[email-masked]>
>> Date: Sun, 26 Aug 2018 23:56:15 -0400
>> Subject: [PATCH 2/9] gnu: Add python-toml.
>>
>> * gnu/packages/python.scm (python-toml, python2-toml): New variables.
>
> [...]
>
>> +    (home-page "https://github.com/uiri/toml")
>> +    (synopsis "Library for TOML")
>> +    (description
>> +     "@code{toml} is a library for Tom's Obvious, Minimal Language (TOML).")
>> +    (license license:expat)))
>
> Maybe “parser” instead of “library”?

I've settled for this, taking inspiration from their project's page:

-     "@code{toml} is a library for Tom's Obvious, Minimal Language (TOML).")
+     "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
+Language (TOML) configuration files.")

>> +(define-public python2-toml
>> +  (package-with-python2 python-toml))
>
> There was a loose consensus that if the Python 2 variant isn’t strictly
> needed, then it’s best not to include it; so I think you can remove it.

Removed.

>> From 46ccd0d7093f9adbe091ec6e7846719e5ad267bf Mon Sep 17 00:00:00 2001
>> From: Maxim Cournoyer <[email-masked]>
>> Date: Mon, 12 Feb 2018 22:08:03 -0500
>> Subject: [PATCH 4/9] gnu: Add emacs-el-x.
>>
>> * gnu/packages/emacs.scm (emacs-el-x): New variable.
>
> [...]
>
>> +    (home-page "https://github.com/sigma/el-x")
>> +    (synopsis "Emacs Lisp extensions")
>> +    (description "Defines the @code{dflet} macro to provide the historic
>> +behavior of @code{flet}, as well as @code{declare-function} stub for older
>> +Emacs.")
>
> Full sentence please.  :-)

It now reads as:

-    (description "Defines the @code{dflet} macro to provide the historic
-behavior of @code{flet}, as well as @code{declare-function} stub for older
-Emacs.")
+    (description "command@{emacs-el-x} defines the @code{dflet} macro to
+provide the historic behavior of @code{flet}, as well as
+@code{declare-function} stub for older Emacs.")

>> +    (arguments
>> +     `(#:phases
>> +       (modify-phases %standard-phases
>> +         (add-before 'check 'set-shell
>> +           ;; Otherwise Emacs shell-file-name is set to "/bin/sh", which doesn't
>> +           ;; work.
>> +           (lambda _
>> +             (setenv "SHELL" (which "sh")))))
>
> This still needs to return #t, though I think Mark’s plan is to put an
> end to that in the next ‘core-updates’ cycle.

Done.

>
>> +    (home-page "https://github.com/antonj/Highlight-Indentation-for-Emacs/")
>> +    (synopsis "Highlighting indentation for Emacs")
>> +    (description "Provides two minor modes to highlight indentation guides in Emacs:
>> +@enumerate
>> +@item @code{highlight-indentation-mode}, which displays guidelines
>> +indentation (space indentation only).
>> +@item @code{ighlight-indentation-current-column-mode}, which displays guidelines for the current-point indentation (space indentation only).
>               ^
> Typo.

Fixed.

>> +    (arguments
>> +     `(#:include (cons* "^elpy\\/" "^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")))
>> +         ;; 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")))))
>
> Likewise for phase return values.

Fixed!

>
>> +    (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.")
>
> If you could expound a little bit on the features (completion?
> navigation? refactoring?), that would be great.

It now reads as:

-and configures a number of other packages written in Emacs Lisp as well
-as Python.")
+and configures a number of other packages written in Emacs Lisp as well as
+Python, together offering features such as navigation, documentation,
+completion, interactive development and more.")

I'm resending the modified full series of patches as v3, for ease of
use.

Thank you for reviewing!

Maxim
>From 82219e988c770cea162fe4f8d8980c7f65964a6a Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 26 Aug 2018 17:34:57 -0400
Subject: [PATCH 01/10] gnu: python-parso: Update to 0.3.1.

* gnu/packages/python.scm (python-parso): Update to 0.3.1.
---
 gnu/packages/python.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index fd1fdbf82..08a4ab2c8 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -13502,14 +13502,14 @@ time-based (TOTP) passwords.")
 (define-public python-parso
   (package
     (name "python-parso")
-    (version "0.2.1")
+    (version "0.3.1")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "parso" version))
        (sha256
         (base32
-         "0zvh4rdhv2wkglkgh0h9kn9ndpsw5p639wcwv47jn1kfp504lq7h"))))
+         "18p89iwcm8mnf380f92g9w0bhx5km8wxp392vvjcq4y1ld1llw1m"))))
     (native-inputs
      `(("python-pytest" ,python-pytest)))
     (build-system python-build-system)
-- 
2.18.0

>From 2aa56bdad52e1758f504df2eb21529b81bd97a4b Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 26 Aug 2018 17:35:46 -0400
Subject: [PATCH 02/10] gnu: python-jedi: Update to 0.12.1.

* gnu/packages/python.scm (python-jedi): Update to 0.12.1.
[propagated-inputs]: Move python-parso here, as it is required at run time.
---
 gnu/packages/python.scm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 08a4ab2c8..c333cfc3a 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -9622,14 +9622,14 @@ characters, mouse support, and auto suggestions.")
 (define-public python-jedi
   (package
     (name "python-jedi")
-    (version "0.12.0")
+    (version "0.12.1")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "jedi" version))
        (sha256
         (base32
-         "1bcr7csx4xil1iwmk03d79jis0bkmgi9k0kir3xa4rmwqsagcwhr"))))
+         "1h8ypnjisn57kiv1zqrkj1im6sbfnhxllqaa8znh39qkd47ys2dl"))))
     (build-system python-build-system)
     (arguments
      `(#:phases
@@ -9638,8 +9638,9 @@ characters, mouse support, and auto suggestions.")
                            (invoke "py.test" "-vv"))))))
     (native-inputs
      `(("python-pytest" ,python-pytest)
-       ("python-parso" ,python-parso)
        ("python-docopt" ,python-docopt)))
+    (propagated-inputs
+     `(("python-parso" ,python-parso)))
     (home-page "https://github.com/davidhalter/jedi")
     (synopsis
      "Autocompletion for Python that can be used for text editors")
-- 
2.18.0

>From b7620ad52298b1787248b898dbe46b14be4b560d Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 26 Aug 2018 23:56:15 -0400
Subject: [PATCH 03/10] gnu: Add python-toml.

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

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index c333cfc3a..27a1378bf 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -54,6 +54,7 @@
 ;;; Copyright © 2018 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2018 Oleg Pykhalov <[email-masked]>
 ;;; Copyright © 2018 Clément Lassieur <[email-masked]>
+;;; Copyright © 2018 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2721,6 +2722,27 @@ which can produce feeds in RSS 2.0, RSS 0.91, and Atom formats.")
 (define-public python2-feedgenerator
   (package-with-python2 python-feedgenerator))
 
+(define-public python-toml
+  (package
+    (name "python-toml")
+    (version "0.9.4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "toml" version))
+       (sha256
+        (base32
+         "0bdbpbip67wdm6c7xwc6mmbmskyradj4cdxn1iibj4fcx1nbv1lf"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f))                     ;no tests suite in release
+    (home-page "https://github.com/uiri/toml")
+    (synopsis "Library for TOML")
+    (description
+     "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
+Language (TOML) configuration files.")
+    (license license:expat)))
+
 (define-public python-blinker
   (package
     (name "python-blinker")
-- 
2.18.0

>From 696b05fe7c47201bff8f9a60818ca5afa60b3df4 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 26 Aug 2018 23:58:26 -0400
Subject: [PATCH 04/10] gnu: Add python-black.

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

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 27a1378bf..5a0551185 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -2743,6 +2743,41 @@ which can produce feeds in RSS 2.0, RSS 0.91, and Atom formats.")
 Language (TOML) configuration files.")
     (license license:expat)))
 
+(define-public python-black
+  (package
+    (name "python-black")
+    (version "18.6b4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "black" version))
+       (sha256
+        (base32
+         "0i4sfqgz6w15vd50kbhi7g7rifgqlf8yfr8y78rypd56q64qn592"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'patch-source-shebangs 'patch-extra-shebangs
+           (lambda _
+             (let ((python3 (which "python3")))
+               (substitute* '("tests/data/fmtonoff.py"
+                              "tests/data/string_prefixes.py"
+                              "tests/data/function.py")
+                 (("#!/usr/bin/env python3(\\.[0-9]+)?" _ minor-version)
+                  (string-append "#!" python3 (if (string? minor-version)
+                                                  minor-version
+                                                  ""))))))))))
+    (propagated-inputs
+     `(("python-click" ,python-click)
+       ("python-attrs" ,python-attrs)
+       ("python-appdirs" ,python-appdirs)
+       ("python-toml" ,python-toml)))
+    (home-page "https://github.com/ambv/black")
+    (synopsis "The uncompromising code formatter")
+    (description "Black is the uncompromising Python code formatter.")
+    (license license:expat)))
+
 (define-public python-blinker
   (package
     (name "python-blinker")
-- 
2.18.0

>From cb7db8bdeb6a8a3ad9832efbef56932979e2ac87 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:08:03 -0500
Subject: [PATCH 05/10] gnu: Add emacs-el-x.

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 08554280c..3a2dac476 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4408,6 +4408,39 @@ If you want to mark a folder manually as a project just create an empty
 and RSS, with a user interface inspired by notmuch.")
     (license license:gpl3+)))
 
+(define-public emacs-el-x
+  (package
+    (name "emacs-el-x")
+    (version "0.3.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/sigma/el-x.git")
+                    (commit (string-append "v" version))))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "1i6j44ssxm1xdg0mf91nh1lnprwsaxsx8vsrf720nan7mfr283h5"))))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         ;; Move the source files to the top level, which is included in
+         ;; the EMACSLOADPATH.
+         (add-after 'unpack 'move-source-files
+           (lambda _
+             (let ((el-files (find-files "./lisp" ".*\\.el$")))
+               (for-each (lambda (f)
+                           (rename-file f (basename f)))
+                         el-files))
+             #t)))))
+    (home-page "https://github.com/sigma/el-x")
+    (synopsis "Emacs Lisp extensions")
+    (description "command@{emacs-el-x} defines the @code{dflet} macro to
+provide the historic behavior of @code{flet}, as well as
+@code{declare-function} stub for older Emacs.")
+    (license license:gpl2+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0

>From 0a5e5ea51be524b2cb5f18cbeaf3710aa787601b Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:08:37 -0500
Subject: [PATCH 06/10] gnu: Add emacs-mocker.

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 3a2dac476..4127cd10a 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4441,6 +4441,34 @@ provide the historic behavior of @code{flet}, as well as
 @code{declare-function} stub for older Emacs.")
     (license license:gpl2+)))
 
+(define-public emacs-mocker
+  (package
+    (name "emacs-mocker")
+    (version "0.3.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/sigma/mocker.el.git")
+                    (commit (string-append "v" version))))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "1lav7am41v63xgavq8pr88y828jmd1cxd4prjq7jlbxm6nvrwxh2"))))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:tests? #t
+       #:test-command '("ert-runner")))
+    (native-inputs
+     `(("ert-runner" ,ert-runner)))
+    (propagated-inputs
+     `(("emacs-el-x" ,emacs-el-x)))
+    (home-page "https://github.com/sigma/mocker.el")
+    (synopsis "Mocking framework for Emacs Lisp")
+    (description "Mocker.el is a framework for writing tests in Emacs Lisp.
+It uses regular Lisp rather than a domain specific language (DSL), which
+maximizes flexibility (at the expense of conciseness).")
+    (license license:gpl2+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0

>From 389884afef7a7107411103eb6fb1a6dca4f99ce6 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:09:12 -0500
Subject: [PATCH 07/10] gnu: Add emacs-find-file-in-project.

* gnu/packages/emacs.scm (emacs-find-file-in-project): New variable.
---
 gnu/packages/emacs.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 4127cd10a..6445e54a3 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4469,6 +4469,39 @@ It uses regular Lisp rather than a domain specific language (DSL), which
 maximizes flexibility (at the expense of conciseness).")
     (license license:gpl2+)))
 
+(define-public emacs-find-file-in-project
+  (package
+    (name "emacs-find-file-in-project")
+    (version "5.4.7")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/technomancy/find-file-in-project.git")
+                    (commit version)))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "1sdnyqv69mipbgs9yax88m9b6crsa59rjhwrih197pifl4089awr"))))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'check 'set-shell
+           ;; Otherwise Emacs shell-file-name is set to "/bin/sh", which doesn't
+           ;; work.
+           (lambda _
+             (setenv "SHELL" (which "sh"))
+             #t)))
+       #:tests? #t
+       #:test-command '("./tests/test.sh")))
+    (home-page "https://github.com/technomancy/find-file-in-project")
+    (synopsis "File/directory finder for Emacs")
+    (description "@code{find-file-in-project} allows to find files or
+directories quickly in the current project.  The project root is detected
+automatically when Git, Subversion or Mercurial are used.  It also provides
+functions to assist in reviewing changes on files.")
+    (license license:gpl3+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0

>From 2d4b239c6dc2ea904bdcbacb19bd7c0c24b2b318 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:09:43 -0500
Subject: [PATCH 08/10] gnu: Add emacs-pyvenv.

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 6445e54a3..aa42ec092 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4502,6 +4502,37 @@ automatically when Git, Subversion or Mercurial are used.  It also provides
 functions to assist in reviewing changes on files.")
     (license license:gpl3+)))
 
+(define-public emacs-pyvenv
+  (package
+    (name "emacs-pyvenv")
+    (version "1.11")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jorgenschaefer/pyvenv.git")
+                    (commit (string-append "v" version))))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "1a346qdimr1dvj53q033aqnahwd2dhyn9jadrs019nm0bzgw7g63"))))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         ;; This phase incorrectly attempts to substitute "activate" and fails
+         ;; doing so.
+         (delete 'patch-el-files))
+       #:tests? #t
+       #:test-command '("ert-runner")))
+    (native-inputs
+     `(("ert-runner" ,ert-runner)
+       ("emacs-mocker" ,emacs-mocker)))
+    (home-page "https://github.com/jorgenschaefer/pyvenv")
+    (synopsis "Virtualenv minor mode for Emacs")
+    (description "pyvenv.el is a minor mode to support using Python virtual
+environments (virtualenv) inside Emacs.")
+    (license license:gpl3+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0

>From 57de32e6190af4a4b92bb66904aa8081875ae366 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 12 Feb 2018 22:10:03 -0500
Subject: [PATCH 09/10] gnu: Add emacs-highlight-indentation.

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index aa42ec092..7381e69dc 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4533,6 +4533,30 @@ functions to assist in reviewing changes on files.")
 environments (virtualenv) inside Emacs.")
     (license license:gpl3+)))
 
+(define-public emacs-highlight-indentation
+  (package
+    (name "emacs-highlight-indentation")
+    (version "0.7.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/antonj/Highlight-Indentation-for-Emacs.git")
+                    (commit (string-append "v" version))))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "00l54k75qk24a0znzl4ij3s3nrnr2wy9ha3za8apphzlm98m907k"))))
+    (build-system emacs-build-system)
+    (home-page "https://github.com/antonj/Highlight-Indentation-for-Emacs/")
+    (synopsis "Highlighting indentation for Emacs")
+    (description "Provides two minor modes to highlight indentation guides in Emacs:
+@enumerate
+@item @code{highlight-indentation-mode}, which displays guidelines
+indentation (space indentation only).
+@item @code{highlight-indentation-current-column-mode}, which displays guidelines for the current-point indentation (space indentation only).
+@end enumerate")
+    (license license:gpl2+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0

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

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 7381e69dc..a0c7acb72 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4557,6 +4557,85 @@ 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"))
+             #t))
+         (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, together offering features such as navigation, documentation,
+completion, interactive development and more.")
+    (license license:gpl3+)))
+
 (define-public emacs-rainbow-delimiters
   (package
     (name "emacs-rainbow-delimiters")
-- 
2.18.0