Subject: [bug#27637] [PATCH 2/2] gnu: Add conda

From: Muriithi Frederick Muriuki <[email-masked]>
Date: Thu, 13 Jul 2017 04:47:26 +0300

* gnu/packages/package-management.scm (conda): New variable.
---
 gnu/packages/package-management.scm | 86 +++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 121a915fb..7fb245d41 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -554,3 +554,89 @@ entirely in Python, and is BSD licensed open source.")
 
 (define-public python2-conda
   (package-with-python2 python-conda))
+
+(define-public conda
+  ;; python-conda is the python library form, to be included in python programs,
+  ;; while conda, here, is the executable form that can be run from the cli
+  (package
+    (inherit python-conda)
+    (name "conda")
+    (version "4.3.16")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/conda/conda/archive/"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "1jq8hyrc5npb5sf4vw6s6by4602yj8f79vzpbwdfgpkn02nfk1dv"))))
+    (arguments
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build
+             'create-version-file
+           (lambda* _
+             (let ((version-file (open-output-file "conda/.version")))
+               (display ,version version-file)
+               (close-output-port version-file)
+               #t)))
+         (replace 'build
+           (lambda* (#:key use-setuptools? #:allow-other-keys)
+             (apply system* "python" "utils/setup-testing.py" "bdist" '())))
+         (add-before 'check
+             'remove-failing-tests
+           (lambda* _
+             ;; these tests try to access /homeless-shelter or
+             ;; require internet/network access
+             (delete-file "tests/test_cli.py")
+             (delete-file "tests/test_create.py")
+             (delete-file "tests/test_export.py")
+             (delete-file "tests/test_connection.py")
+             (delete-file "tests/test_fetch.py")
+             (delete-file "tests/test_info.py")
+             (delete-file "tests/test_install.py")
+             (delete-file "tests/test_plan.py")
+             (delete-file "tests/test_history.py")
+             (delete-file "tests/test_priority.py")
+             (delete-file "tests/conda_env/test_env.py")
+             (delete-file "tests/conda_env/test_cli.py")
+             (delete-file "tests/core/test_repodata.py")
+             (delete-file "tests/conda_env/test_create.py")
+             (delete-file "tests/conda_env/specs/test_binstar.py")
+             (delete-file "tests/conda_env/utils/test_uploader.py")
+             (delete-file "tests/conda_env/specs/test_notebook.py")
+             (delete-file "tests/conda_env/utils/test_notebooks.py")
+             (delete-file "tests/core/test_index.py")
+             (delete-file "tests/gateways/disk/test_delete.py")))
+         (replace 'check
+           (lambda* _
+             (zero? (system* "py.test"))))
+         (replace 'install
+           (lambda* (#:key outputs target (configure-flags '())
+                     use-setup-tools? #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (main-dir (getcwd))
+                    (build-dir (string-append main-dir "/build"))
+                    (dist-dir (string-append main-dir "/dist"))
+                    (dir-stream (opendir dist-dir))
+                    (tar-file (let get-file ((stream dir-stream))
+                                (let ((the-file ""))
+                                  (do ((file (readdir stream) (readdir stream)))
+                                      ((eof-object? file))
+                                    (if (not (or (equal? file ".")
+                                                 (equal? file "..")))
+                                        (set! the-file file)))
+                                  the-file))))
+               (closedir dir-stream)
+               (chdir dist-dir)
+               ;; tar seems to be ignoring the -C option and at this point
+               ;; the path in the variable `out` does not seem to exist, hence
+               ;; the need for the hack-y code that follows.
+               (mkdir "tmp")
+               (chdir "tmp")
+               (system* "tar" "-xvzf" (string-append "../" tar-file)
+                        "--strip-components=4")
+               (chdir "../")
+               (system* "cp" "-fvR" "tmp/" out)
+               (chdir main-dir)))))))))
-- 
2.13.2