diff mbox series

[bug#67813,12/12] gnu: python-pandas: Update to 2.1.1.

Message ID 20231213215635.15562-12-ngraves@ngraves.fr
State New
Headers show
Series [bug#67813,01/12] gnu: meson/newer: Update to 1.2.1. | expand

Commit Message

Nicolas Graves Dec. 13, 2023, 9:56 p.m. UTC
* gnu/packages/python-science.scm (python-pandas): Update to 2.1.1.
[source]: Use git origin.
[build-system]: Use pyproject-build-system.
[arguments]:
  (modules): Remove argument.
  (test-flags): Add required test flags.
  (phases): Add phase version-set-by-guix and pre-check.
  Remove phase enable-parallel-build. Remove check phase
  replacement.
[propagated-inputs]: Add package python-tzdata.
[native-inputs]: Add meson-python, python-versioneer python-matplotlib,
python-openpyxl, python-asyncio, python-pytest-localserver. Replace
python-pytest by python-pytest-next.
---
 gnu/packages/python-science.scm | 132 +++++++++++++++++---------------
 1 file changed, 72 insertions(+), 60 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/python-science.scm b/gnu/packages/python-science.scm
index 2e238dc198..09d130537f 100644
--- a/gnu/packages/python-science.scm
+++ b/gnu/packages/python-science.scm
@@ -468,75 +468,81 @@  (define-public python-tspex
 (define-public python-pandas
   (package
     (name "python-pandas")
-    (version "1.4.4")
+    (version "2.1.1")
     (source
      (origin
-       (method url-fetch)
-       (uri (pypi-uri "pandas" version))
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/pandas-dev/pandas")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
        (sha256
-        (base32 "0ryv66s9cvd27q6a985vv556k2qlnlrdna2z7qc7bdhphrrhsv5b"))))
-    (build-system python-build-system)
+        (base32 "1v9j38bvw739csdfl98ga6fqjdm61q3p5a2l7h364kg925nbc9r1"))))
+    (build-system pyproject-build-system)
     (arguments
-     `(#:modules ((guix build utils)
-                  (guix build python-build-system)
-                  (ice-9 ftw)
-                  (srfi srfi-1)
-                  (srfi srfi-26))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'enable-parallel-build
-           (lambda _
-             (substitute* "setup.py"
-               (("\"-j\", type=int, default=1")
-                (format #f "\"-j\", type=int, default=~a"
-                        (parallel-job-count))))))
-         (add-after 'unpack 'patch-which
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((which (assoc-ref inputs "which")))
-               (substitute* "pandas/io/clipboard/__init__.py"
-                 (("^WHICH_CMD = .*")
-                  (string-append "WHICH_CMD = \"" which "\"\n"))))))
-         (add-before 'check 'prepare-x
-           (lambda _
-             (system "Xvfb &")
-             (setenv "DISPLAY" ":0")
-             ;; xsel needs to write a log file.
-             (setenv "HOME" "/tmp")))
-         (replace 'check
-           (lambda* (#:key tests? #:allow-other-keys)
-             (let ((build-directory
-                    (string-append
-                     (getcwd) "/build/"
-                     (first (scandir "build"
-                                     (cut string-prefix? "lib." <>))))))
-               (substitute* "pyproject.toml"
-                 ;; Not all data files are distributed with the tarball.
-                 (("--strict-data-files ") ""))
-               (with-directory-excursion build-directory
-                 (when tests?
-                   (invoke "pytest" "-vv" "pandas" "--skip-slow"
-                           "--skip-network"
-                           "-n" (number->string (parallel-job-count))
-                           "-k"
-                           (string-append
-                            ;; These test access the internet (see:
-                            ;; https://github.com/pandas-dev/pandas/issues/45085).:
-                            ;; pandas/tests/io/xml/test_xml.py::test_wrong_url[lxml]
-                            ;; pandas/tests/io/xml/test_xml.py::test_wrong_url[etree]
-                            "not test_wrong_url"
-                            ;; TODO: Missing input
-                            " and not TestS3"
-                            " and not s3"
-                            ;; This test fails when run with pytest-xdist
-                            ;; (see:
-                            ;; https://github.com/pandas-dev/pandas/issues/39096).
-                            " and not test_memory_usage"))))))))))
+     (list
+      #:test-flags
+      #~(list "--pyargs" "pandas"
+              ;; "--exitfirst"
+              ;; FIXME "-n" (number->string (parallel-job-count))
+              "-m" "not slow and not network and not db"
+              "-k" (string-append
+                    "not test_git_version"
+                    " and not test_show_versions_console"
+                    ;; Not testing ~ expansion.
+                    " and not test_expand_user"
+                    " and not test_get_handle_with_path"
+                    ;; These test access the internet (see:
+                    ;; https://github.com/pandas-dev/pandas/issues/45085).:
+                    ;; pandas/tests/io/xml/test_xml.py::test_wrong_url[lxml]
+                    ;; pandas/tests/io/xml/test_xml.py::test_wrong_url[etree]
+                    " and not test_wrong_url"
+                    ;; TODO: Missing input
+                    " and not TestS3"
+                    " and not s3"
+                    ;; This test fails when run with pytest-xdist
+                    ;; (see: https://github.com/pandas-dev/pandas/issues/39096).
+                    " and not test_memory_usage"
+                    " and not test_parsing_tzlocal_deprecated"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'version-set-by-guix
+            (lambda _
+              (with-output-to-file "_version_meson.py"
+                (lambda _
+                  (display
+                   (string-append "__version__ = \""
+                                  #$(package-version this-package)
+                                  "\""))))))
+          (add-before 'check 'prepare-x
+            (lambda _
+              (system "Xvfb &")
+              (setenv "DISPLAY" ":0")
+              (setenv "HOME" ".")))
+          (add-after 'unpack 'patch-which
+            (lambda _
+              (substitute* "pandas/io/clipboard/__init__.py"
+                (("^WHICH_CMD = .*")
+                 (string-append "WHICH_CMD = \""
+                                #$(this-package-input "which")
+                                "/bin/which\"\n")))))
+          ;; The compiled libraries are only in the output at this point,
+          ;; but they are needed to run tests.
+          ;; FIXME: This should be handled by the pyargs pytest argument,
+          ;; but is not for some reason.
+          (add-before 'check 'pre-check
+            (lambda _
+              (copy-recursively
+               (string-append #$output
+                              "/lib/python3.10/site-packages/pandas/_libs")
+               "pandas/_libs"))))))
     (propagated-inputs
      (list python-jinja2
            python-numpy
            python-openpyxl
            python-pytz
            python-dateutil
+           python-tzdata
            python-xlrd
            python-xlsxwriter))
     (inputs
@@ -546,9 +552,15 @@  (define-public python-pandas
            python-beautifulsoup4
            python-lxml
            python-html5lib
-           python-pytest
+           meson-python
+           python-matplotlib
+           python-openpyxl
+           python-pytest-next
+           python-pytest-asyncio
+           python-pytest-localserver
            python-pytest-mock
            python-pytest-xdist
+           python-versioneer
            ;; Needed to test clipboard support.
            xorg-server-for-tests))
     (home-page "https://pandas.pydata.org")