diff mbox series

[bug#70855,21/92] gnu: conda: Move to pyproject-build-system.

Message ID 20240509225530.24649-21-ngraves@ngraves.fr
State New
Headers show
Series python-team patches | expand

Commit Message

Nicolas Graves May 9, 2024, 10:53 p.m. UTC
* gnu/packages/package-management.scm (conda): Improve package style.
  [build-system]: Move to pyproject-build-system.
  [arguments]<#:test-flags>: Use field instead of check phase
  replacement.
  <#:phases>: Remove check phase replacement. Improve use of format in
  phase do-not-use-python-root-as-prefix. Use gexp. Put phase init
  after phase create-entrypoints.

Change-Id: Id1affbf8f80fae2882e4c8a88b1e817cf49a5c00
---
 gnu/packages/package-management.scm | 104 +++++++++++++---------------
 1 file changed, 50 insertions(+), 54 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index f4c2cf91492..8a47135ad02 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -1170,10 +1170,49 @@  (define-public conda
        (sha256
         (base32
          "16vz4vx311ry9w35mi5wna8p8n3abd6wdqrpqzjfdlwv7hcr44s4"))))
-    (build-system python-build-system)
+    (build-system pyproject-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
+     (list
+      #:test-flags
+      '(list
+        "--ignore=tests/cli/test_main_clean.py"
+        "--ignore=tests/cli/test_main_rename.py"
+        "-k" (string-append
+              "not "
+              (string-join
+               (list
+                "integration"
+                ;; This one reports a newer version of conda than
+                ;; expected; conda-1.5.2-py27_0 instead of
+                ;; conda-1.3.5-py27_0.
+                "test_auto_update_conda"
+                ;; This fails because the output directory is not a
+                ;; Conda environment.
+                "test_list"
+                ;; This fails because we patched the default root
+                ;; prefix.
+                "test_default_target_is_root_prefix"
+                ;; This fails because of missing features in python-flaky.
+                "test_no_features"
+                ;; These fail because they require network access
+                "test_no_ssl"
+                "test_run_readonly_env"
+                "test_run_returns_int"
+                "test_run_returns_nonzero_errorlevel"
+                "test_run_returns_zero_errorlevel"
+                "test_run_uncaptured"
+
+                ;; TODO: I don't understand what this failure means
+                "test_PrefixData_return_value_contract"
+                ;; TODO: same here
+                "test_install_1"
+                ;; Not sure if this is really wrong.  This fails because
+                ;; /gnu/store/...conda-22.9.0/bin/python
+                ;; is not /gnu/store/...python-wrapper-3.9.9/bin/python
+                "test_make_entry_point")
+               " and not ")))
+      #:phases
+     #~(modify-phases %standard-phases
          ;; The default version of pytest does not support these options.
          (add-after 'unpack 'use-older-pytest
            (lambda _
@@ -1186,10 +1225,6 @@  (define-public conda
          (add-after 'unpack 'correct-python-executable-name
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((python (assoc-ref inputs "python-wrapper")))
-               #;
-               (substitute* "conda/common/path.py"
-                 (("python_version or ''")
-                  "python_version or '3'"))
                (substitute* "conda/core/initialize.py"
                  (("python_exe = join")
                   (format #f "python_exe = \"~a/bin/python\" #"
@@ -1200,19 +1235,19 @@  (define-public conda
                    (python (assoc-ref inputs "python-wrapper")))
                (substitute* "tests/core/test_initialize.py"
                  (("\"\"\"\\) % conda_prefix")
-                  (format #f "\"\"\") % \"~a\"" python))
+                  (format #f "\"\"\") % ~s" python))
                  (("CONDA_PYTHON_EXE \"%s\"' % join\\(conda_prefix")
-                  (format #f "CONDA_PYTHON_EXE \"%s\"' % join(\"~a\""
+                  (format #f "CONDA_PYTHON_EXE \"%s\"' % join(~s"
                           python))
                  (("conda_prefix = abspath\\(sys.prefix\\)")
-                  (format #f "conda_prefix = abspath(\"~a\")" out)))
+                  (format #f "conda_prefix = abspath(~s)" out)))
                (substitute* "conda/base/context.py"
                  (("os.chdir\\(sys.prefix\\)")
-                  (format #f "os.chdir(\"~a\")" out))
+                  (format #f "os.chdir(~s)" out))
                  (("sys.prefix, '.condarc'")
-                  (format #f "\"~a\", '.condarc'" out))
+                  (format #f "~s, '.condarc'" out))
                  (("return abspath\\(sys.prefix\\)")
-                  (format #f "return abspath(\"~a\")" out))
+                  (format #f "return abspath(~s)" out))
                  (("os.path.join\\(sys.prefix, bin_dir, exe\\)")
                   (format #f "\"~a/bin/conda\"" out))
                  (("'CONDA_EXE', sys.executable")
@@ -1220,47 +1255,8 @@  (define-public conda
          (add-before 'build 'create-version-file
            (lambda _
              (with-output-to-file "conda/.version"
-               (lambda () (display ,version)))))
-         (replace 'check
-           (lambda* (#:key tests? #:allow-other-keys)
-             ;; These tests all require network access.
-             (for-each delete-file '("tests/cli/test_main_clean.py"
-                                     "tests/cli/test_main_rename.py"))
-             (when tests?
-               (setenv "HOME" "/tmp")
-               (invoke "py.test" "-vv"
-                       "-k"
-                       (string-append
-                        "not integration"
-                        ;; This one reports a newer version of conda than
-                        ;; expected; conda-1.5.2-py27_0 instead of
-                        ;; conda-1.3.5-py27_0.
-                        " and not test_auto_update_conda"
-                        ;; This fails because the output directory is not a
-                        ;; Conda environment.
-                        " and not test_list"
-                        ;; This fails because we patched the default root
-                        ;; prefix.
-                        " and not test_default_target_is_root_prefix"
-                        ;; This fails because of missing features in python-flaky.
-                        " and not test_no_features"
-                        ;; These fail because they require network access
-                        " and not test_no_ssl"
-                        " and not test_run_readonly_env"
-                        " and not test_run_returns_int"
-                        " and not test_run_returns_nonzero_errorlevel"
-                        " and not test_run_returns_zero_errorlevel"
-                        " and not test_run_uncaptured"
-
-                        ;; TODO: I don't understand what this failure means
-                        " and not test_PrefixData_return_value_contract"
-                        ;; TODO: same here
-                        " and not test_install_1"
-                        ;; Not sure if this is really wrong.  This fails because
-                        ;; /gnu/store/...conda-22.9.0/bin/python
-                        ;; is not /gnu/store/...python-wrapper-3.9.9/bin/python
-                        " and not test_make_entry_point")))))
-         (add-after 'install 'init
+               (lambda () (display #$version)))))
+         (add-after 'create-entrypoints 'init
            ;; This writes a whole bunch of shell initialization files to the
            ;; prefix directory.  Many features of conda can only be used after
            ;; running "conda init".