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

From: Pjotr Prins <[email-masked]>
Date: Fri, 21 Jul 2017 07:48:58 +0200

Thanks Fred.

Can someone take a look at the tar issue?

If there are no objections, please push.

On Tue, Jul 18, 2017 at 11:37:09AM +0300, Muriithi Frederick Muriuki wrote:
> * gnu/packages/package-management.scm (conda): New variable.
> ---
>  gnu/packages/package-management.scm | 84 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
> index 3f106a65e..b30b8aff0 100644
> --- a/gnu/packages/package-management.scm
> +++ b/gnu/packages/package-management.scm
> @@ -693,3 +693,87 @@ entirely in Python, and is BSD licensed open source.")
>  
>  (define-public python2-conda
>    (package-with-python2 python-conda))
> +
> +(define-public conda
> +  (package
> +    (inherit python-conda)
> +    (name "conda")
> +    (version "4.3.16")
> +    (arguments
> +     `(#: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* _
> +             ;; the util/setup-testing.py is used to build conda in
> +             ;; application form, rather than the default, library form.
> +             ;; With this, we are able to run commands like `conda --help`
> +             ;; directly on the command line
> +             (zero? (system* "python" "utils/setup-testing.py" "bdist"))))
> +         (add-before 'check
> +             'remove-failing-tests
> +           (lambda* _
> +             ;; these tests 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_fetch.py")
> +             (delete-file "tests/test_history.py")
> +             (delete-file "tests/test_info.py")
> +             (delete-file "tests/test_install.py")
> +             (delete-file "tests/test_priority.py")
> +             (delete-file "tests/conda_env/test_cli.py")
> +             (delete-file "tests/conda_env/test_create.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/core/test_repodata.py")
> +             ;; This last test creates a file, then deletes it an
> +             ;; tests that the file was deleted. For some reason
> +             ;; it fails when building with guix, but does not when
> +             ;; you run it in the directory left when you build with
> +             ;; the --keep-failed option
> +             (delete-file "tests/gateways/disk/test_delete.py")))
> +         (replace 'check
> +           (lambda* _
> +             (and
> +              (setenv "HOME" "/tmp")
> +              (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 hacky
> +               ;; 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
> 
> 
> 
> 

--