Subject: [bug#65758] [PATCH v7 31/57] gnu: python-django-haystack: Update to 3.2.1.

From: Nicolas Graves <[email-masked]>
Date: Wed, 6 Sep 2023 11:15:55 +0200

* gnu/packages/django.scm (python-django-haystack): Update to 3.2.1.
[build-system]: Use pyproject-build-system.
[arguments](phases): Delete phase loosen-version-restrictions. Extend and
rename phase set-gdal-lib-path to set-lib-path, add phase check.
(tests?): Delete argument.
[native-inputs]: Add geos. Delete python-pysolr.
---
 gnu/packages/django.scm | 60 ++++++++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/django.scm b/gnu/packages/django.scm
index 008c5a44f2..0bcac0c07a 100644
--- a/gnu/packages/django.scm
+++ b/gnu/packages/django.scm
@@ -473,34 +473,63 @@ (define-public python-pytest-django
 (define-public python-django-haystack
   (package
     (name "python-django-haystack")
-    (version "3.1.1")
+    (version "3.2.1")
     (source
       (origin
         (method url-fetch)
         (uri (pypi-uri "django-haystack" version))
         (sha256
-         (base32
-          "10kaa5641cakpra2x3jqgys085gdkjcyns26plfyrmfpjmmpa1bd"))))
-    (build-system python-build-system)
+         (base32 "194kf9ps1h8bq8q32x6nniy85grl4l5605vgbd0gw9f2xxx1kqwp"))))
+    (build-system pyproject-build-system)
     (arguments
      '(#:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'loosen-verion-restrictions
-           (lambda _
-             (substitute* "setup.py"
-               (("geopy.*") "geopy\",\n"))))
-         (add-before 'check 'set-gdal-lib-path
+         (add-before 'check 'set-lib-path
            (lambda* (#:key inputs #:allow-other-keys)
-             (setenv "GDAL_LIBRARY_PATH"
-                     (string-append (assoc-ref inputs "gdal")
-                                    "/lib"))))
+             (setenv "LD_LIBRARY_PATH"
+                     (string-append
+                      (assoc-ref inputs "gdal") "/lib"
+                      ":" (assoc-ref inputs "geos") "/lib"))))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (begin
+                 ;; Delete absent elasticsearch tests.
+                 (delete-file-recursively "test_haystack/elasticsearch_tests")
+                 (delete-file-recursively "test_haystack/elasticsearch2_tests")
+                 (delete-file-recursively "test_haystack/elasticsearch5_tests")
+                 (delete-file-recursively "test_haystack/elasticsearch7_tests")
+                 ;; Solr tests require a running solr server.
+                 ;; Deactivating solr.
+                 (delete-file-recursively "test_haystack/solr_tests")
+                 (delete-file "haystack/backends/solr_backend.py")
+                 (delete-file
+                  "haystack/management/commands/build_solr_schema.py")
+                 (delete-file
+                  "test_haystack/test_altered_internal_names.py")
+                 (delete-file "test_haystack/multipleindex/tests.py")
+                 (delete-file "test_haystack/spatial/test_spatial.py")
+                 (substitute* "test_haystack/test_loading.py"
+                   (("class ConnectionHandlerTestCase" all)
+                    (string-append
+                     "\nfrom nose.plugins.attrib import attr"
+                     "\n@attr('skip')"
+                     "\n" all)))
+                 (substitute* "test_haystack/settings.py"
+                   (("\"solr\":")
+                    (string-append
+                     "\"solr\": {\"ENGINE\": \"test_haystack.mocks.MockEngine\"}}"
+                     "\n_={\"solr\":")))
+                 ;; Run tests.
+                 (invoke "django-admin"
+                         "test" "--settings=test_haystack.settings"
+                         "--pythonpath=.")))))
          ;; Importing this module requires setting up a Django project.
-         (delete 'sanity-check))
-       #:tests? #f)) ; OSError: libgdal.so.27: cannot open shared object file
+              (delete 'sanity-check))))
     (propagated-inputs
      (list python-django))
     (native-inputs
-     (list gdal
+     (list gdal geos
            python-coverage
            python-dateutil
            python-geopy
@@ -508,7 +537,6 @@ (define-public python-django-haystack
            python-nose
            python-requests
            python-setuptools-scm
-           python-pysolr
            python-whoosh))
     (home-page "https://haystacksearch.org/")
     (synopsis "Pluggable search for Django")
-- 
2.41.0