Subject: [bug#49207] gnu: Add python-iris. (scitools)

From: Vinicius Monego <[email-masked]>
Date: Thu, 24 Jun 2021 12:39:15 +0000

From 99e02748ab5374266677f47a409749475b4ef8fc Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Mon, 24 May 2021 18:10:18 -0300
Subject: [PATCH 1/6] gnu: Add python-imagehash.

* gnu/packages/python-xyz.scm (python-imagehash): New variable.
---
 gnu/packages/python-xyz.scm | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index ec4209108f..c6d8fb1eea 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -13018,6 +13018,47 @@ The API is as much as possible the similar to jQuery.  pyquery uses lxml for
 fast xml and html manipulation.")
     (license license:bsd-3)))
 
+(define-public python-imagehash
+  (package
+    (name "python-imagehash")
+    (version "4.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "ImageHash" version))
+       (sha256
+        (base32 "0kgiksjggw2warfz5d04fr3iph47vwxcb8jrlj41ljkhrc3ahsd9"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (replace 'check
+           (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+             (when tests?
+               (add-installed-pythonpath inputs outputs)
+               (invoke "pytest")))))))
+    (native-inputs
+     `(("python-pytest" ,python-pytest)))
+    (propagated-inputs
+     `(("python-numpy" ,python-numpy)
+       ("python-pillow" ,python-pillow)
+       ("python-pywavelets" ,python-pywavelets)
+       ("python-scipy" ,python-scipy)
+       ("python-six" ,python-six)))
+    (home-page "https://github.com/JohannesBuchner/imagehash")
+    (synopsis "Image hashing library")
+    (description "ImageHash is an Image hashing library.  It supports:
+
+@itemize
+@item Average hashing
+@item Perceptual hashing
+@item Difference hashing
+@item Wavelet hashing
+@item HSV color hashing (colorhash)
+@item Crop-resistant hashing
+@end itemize")
+    (license license:bsd-2)))
+
 (define-public python-anyjson
   (package
     (name "python-anyjson")
-- 
2.32.0

From 4157cb6a4cc43ba529d71b26729cbbd55ce0c9d3 Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Mon, 24 May 2021 18:22:34 -0300
Subject: [PATCH 2/6] gnu: Add python-xxhash.

* gnu/packages/python-xyz.scm (python-xxhash): New variable.
---
 gnu/packages/python-xyz.scm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index c6d8fb1eea..e1ec61fb0c 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -131,6 +131,7 @@
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages dbm)
+  #:use-module (gnu packages digest)
   #:use-module (gnu packages djvu)
   #:use-module (gnu packages docker)
   #:use-module (gnu packages enchant)
@@ -13059,6 +13060,31 @@ fast xml and html manipulation.")
 @end itemize")
     (license license:bsd-2)))
 
+(define-public python-xxhash
+  (package
+    (name "python-xxhash")
+    (version "2.0.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "xxhash" version))
+       (sha256
+        (base32 "0jbvz19acznq00544gcsjg05fkvrmwbnwdfgrvwss3i1ys6avgmp"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'use-system-xxhash
+           (lambda _
+             (setenv "XXHASH_LINK_SO" "1"))))))
+    (inputs
+     `(("xxhash" ,xxhash)))
+    (home-page "https://github.com/ifduyue/python-xxhash")
+    (synopsis "Python binding for xxHash")
+    (description "This package provides a Python interface binding for the
+xxHash non-cryptographic hash algorithm.")
+    (license license:bsd-2)))
+
 (define-public python-anyjson
   (package
     (name "python-anyjson")
-- 
2.32.0

From bd87844e37388d54598bb5638c3e6368f8f8b014 Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Mon, 24 May 2021 18:32:59 -0300
Subject: [PATCH 3/6] gnu: Add python-antlr4.

* gnu/packages/python-xyz.scm (python-antlr4): New variable.
---
 gnu/packages/python-xyz.scm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index e1ec61fb0c..b102e1c570 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -13085,6 +13085,25 @@ fast xml and html manipulation.")
 xxHash non-cryptographic hash algorithm.")
     (license license:bsd-2)))
 
+(define-public python-antlr4
+  (package
+    (name "python-antlr4")
+    (version "4.7.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "antlr4-python3-runtime" version))
+       (sha256
+        (base32 "02xm7ccsf51vh4xsnhlg6pvchm1x3ckgv9kwm222w5drizndr30n"))))
+    (arguments
+     `(#:tests? #f)) ; there are no tests
+    (build-system python-build-system)
+    (home-page "https://www.antlr.org")
+    (synopsis "ANTLR runtime for Python")
+    (description
+     "This package provides a ANTLR runtime for Python.")
+    (license license:bsd-3)))
+
 (define-public python-anyjson
   (package
     (name "python-anyjson")
-- 
2.32.0

From 9b7690968faf0a5a0452f3eee47a486aea11bfda Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Wed, 26 May 2021 13:33:30 -0300
Subject: [PATCH 4/6] gnu: Add python-cf-units.

* gnu/packages/geo.scm (python-cf-units): New variable.
---
 gnu/packages/geo.scm | 47 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 546be33e55..3ea7804725 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -58,6 +58,7 @@
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
@@ -970,6 +971,52 @@ Shapely capabilities
 @end itemize")
     (license license:lgpl3+)))
 
+(define-public python-cf-units
+  (package
+    (name "python-cf-units")
+    (version "2.1.5")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "cf-units" version))
+       (sha256
+        (base32 "0cswphn1cw0qyzglcn4xinr3pfhvbsdyll4hnb702fsfxv9q2cyl"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'disable-doctest
+           (lambda _
+             ;; Two doctests fail.
+             (substitute* "setup.cfg" (("--doctest-modules") ""))))
+         (replace 'check
+           (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+             (when tests?
+               (add-installed-pythonpath inputs outputs)
+               (invoke "pytest" "--pyargs" "cf_units" "-ra"
+                       ;; This test failed.
+                       "-k" "not test_masked_ndarray")))))))
+    (native-inputs
+     `(("python-coveralls" ,python-coveralls)
+       ("python-cython" ,python-cython)
+       ("python-jinja2" ,python-jinja2)
+       ("python-pep8" ,python-pep8)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-runner" ,python-pytest-runner)))
+    (inputs
+     `(("udunits" ,udunits)))
+    (propagated-inputs
+     `(("python-antlr4" ,python-antlr4)
+       ("python-cftime" ,python-cftime)
+       ("python-numpy" ,python-numpy)
+       ("python-six" ,python-six)))
+    (home-page "https://github.com/SciTools/cf-units")
+    (synopsis "Units of measure as required by the CF metadata conventions")
+    (description "This package provides units of measure as required by the
+Climate and Forecast (CF) metadata conventions.")
+    (license license:lgpl3)))
+
 (define-public postgis
   (package
     (name "postgis")
-- 
2.32.0

From f5425a307ca32542b92f79dad584e8c81b10b8bb Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Thu, 27 May 2021 16:49:27 -0300
Subject: [PATCH 5/6] gnu: Add python-pyke.

* gnu/packages/python-xyz.scm (python-pyke): New variable.
---
 gnu/packages/python-xyz.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index b102e1c570..3925a96b77 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -5918,6 +5918,39 @@ operators such as union, intersection, and difference.")
 search in Python.")
     (license license:lgpl3+)))
 
+(define-public python-pyke
+  (package
+    (name "python-pyke")
+    (version "1.1.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "scitools-pyke" version))
+       (sha256
+        (base32 "0q7nxd0gw135922ck155w2nj2vf47k7cgzdqipxlyrgq6q3lkinl"))))
+    (build-system python-build-system)
+    ;; FIXME: two tests are failing with:
+    ;; "AttributeError: 'fc_tests' object has no attribute 'engine'.".
+    (arguments
+     `(#:tests? #f))
+    (home-page "https://sourceforge.net/projects/pyke/")
+    (synopsis "Python Knowledge Engine")
+    (description "Pyke is a Python Knowledge Engine and automatic Python
+program generator.  Both forward-chaining and backward-chaining rules (which
+may include Python code) are compiled into Python.  It can also automatically
+assemble Python programs out of Python functions which are attached to
+backward-chaining rules.
+
+Features:
+
+@itemize
+@item Automatic programming: generates Python programs.
+@item Forward and backward chaining.
+@item Multiple knowledge engines and rule bases.
+@item Rule-based inheritance.
+@end itemize")
+    (license license:expat)))
+
 (define-public python-wurlitzer
   (package
     (name "python-wurlitzer")
-- 
2.32.0

From c6c77fe7c130274b5b68ac6fd283bba4dad382ae Mon Sep 17 00:00:00 2001
From: Vinicius Monego <[email-masked]>
Date: Mon, 24 May 2021 18:43:03 -0300
Subject: [PATCH 6/6] gnu: Add python-iris.

* gnu/packages/geo.scm (python-iris): New variable.
---
 gnu/packages/geo.scm | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 3ea7804725..65d43849df 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -92,6 +92,7 @@
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-build)
   #:use-module (gnu packages python-check)
   #:use-module (gnu packages python-science)
   #:use-module (gnu packages python-web)
@@ -1017,6 +1018,72 @@ Shapely capabilities
 Climate and Forecast (CF) metadata conventions.")
     (license license:lgpl3)))
 
+(define-public python-iris
+  (package
+    (name "python-iris")
+    (version "3.0.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "scitools-iris" version))
+       (sha256
+        (base32 "1zqicscnnfqpck960xdjng38qk0w0spmcysl89l3smagdsagzxkr"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Some tests require a writable home.
+             (setenv "HOME" "/tmp")
+             ;; Iris will check for "scitools-iris[test]" before running the
+             ;; tests.  The complete test set weighs 150MB.  Skip this check.
+             (substitute* "setup.py"
+               ((".*tests_require.*") ""))
+             ;; The tests below open external connections.
+             (substitute*
+                 "lib/iris/tests/integration/plot/test_vector_plots.py"
+               (("test_2d_plain_latlon") "_test_2d_plain_latlon")
+               (("test_2d_plain_latlon_on_polar_map")
+                "_test_2d_plain_latlon_on_polar_map")
+               (("test_2d_rotated_latlon") "_test_2d_rotated_latlon"))
+             (substitute*
+                 "lib/iris/tests/integration/plot/test_plot_2d_coords.py"
+               (("test_2d_coords_contour") "_test_2d_coords_contour"))
+             ;; This one fails with AssertionError.
+             (substitute* "lib/iris/tests/experimental/test_animate.py"
+               (("test_cube_animation") "_test_cube_animation"))
+             ;; Compile Pyke rules before running the tests.
+             (invoke "python" "setup.py" "pyke_rules"))))))
+    (propagated-inputs
+     `(("python-cartopy" ,python-cartopy)
+       ("python-cf-units" ,python-cf-units)
+       ("python-cftime" ,python-cftime)
+       ("python-dask" ,python-dask)
+       ("python-matplotlib" ,python-matplotlib)
+       ("python-netcdf4" ,python-netcdf4)
+       ("python-numpy" ,python-numpy)
+       ("python-scipy" ,python-scipy)
+       ("python-xxhash" ,python-xxhash)))
+    (native-inputs
+     `(("netcdf" ,netcdf)
+       ("python-black" ,python-black)
+       ("python-filelock" ,python-filelock)
+       ("python-imagehash" ,python-imagehash)
+       ("python-nose" ,python-nose)
+       ("python-pillow" ,python-pillow)
+       ("python-pyke" ,python-pyke)
+       ("python-requests" ,python-requests)
+       ("python-wheel" ,python-wheel)))
+    (home-page "https://github.com/SciTools/iris")
+    (synopsis "Library for analysing and visualising Earth science data")
+    (description "Iris is a Python library for analysing and visualising Earth
+science data.  It excels when working with multi-dimensional Earth Science
+data, where tabular representations become unwieldy and inefficient.  Iris
+implements a data model based on the CF conventions.")
+    ;; See iris/docs/src/copyright.rst.
+    (license license:lgpl3+)))
+
 (define-public postgis
   (package
     (name "postgis")
-- 
2.32.0