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

From: Marius Bakke <[email-masked]>
Date: Sun, 16 Jul 2017 23:09:25 +0200

Muriithi Frederick Muriuki <[email-masked]> writes:

> * gnu/packages/package-management.scm (conda): New variable.

Thanks!

> +(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

The previous patch also creates "$out/bin/conda". Does that executable
not work? Why do we need both packages?

> +  (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

There are a few phases that messes with the tests, yet they are
disabled. Why?

> +       #: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

Often tests using /homeless-shelter just needs the HOME variable set to
some other (writable) directory (typically /tmp).

> +             (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)))))))))

Wooow. What happens with the default 'python setup.py install'?

Unless there exists a good reason to both have a "conda" package and a
'python-conda', I think we should consolidate these two. The previous
patch (from PyPi) did not have tests either, so I suppose we should use
this release (but we should really figure out why setup.py is broken).