Subject: [bug#58261] [PATCH v3 14/15] gnu: Add ringdecomposerlib.

From: David Elsing <[email-masked]>
Date: Thu, 13 Oct 2022 21:04:23 +0000

* gnu/packages/chemistry.scm (ringdecomposerlib): New variable.
---
 gnu/packages/chemistry.scm | 81 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm
index 82bc3ae29e..1a80bd1ad5 100644
--- a/gnu/packages/chemistry.scm
+++ b/gnu/packages/chemistry.scm
@@ -1022,3 +1022,84 @@ (define-public avalon-toolkit
 canonicalization of SMILES and MOL files, molecular structure fingerprinting
 and rendering molecules.")
     (license license:bsd-3)))
+
+(define-public ringdecomposerlib
+  (package
+    (name "ringdecomposerlib")
+    (version "1.1.3")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/rareylab/RingDecomposerLib")
+                    (commit (string-append "v" version "_rdkit"))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1rxzs2wpkkdi40wdzxc4sn0brk7dm7ivgqyfh38gf2f5c7pbg0wi"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:configure-flags
+      #~(list "-DBUILD_PYTHON_WRAPPER=ON"
+              "-DPYTHON_EXECUTABLE=python3"
+              (string-append "-DPYTHON_FLAGS=;--prefix=" #$output ";--root=/"))
+      #:imported-modules (append %cmake-build-system-modules
+                                 '((guix build python-build-system)))
+      #:modules '((guix build cmake-build-system)
+                  (guix build utils)
+                  ((guix build python-build-system)
+                   #:select (add-installed-pythonpath)))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'patch-cmake
+            (lambda _
+              (substitute* (list "src/Test/CMakeLists.txt"
+                                 "src/RingDecomposerLib/CMakeLists.txt")
+                (("build_.*STATIC") "#"))
+              (substitute* "test/CMakeLists.txt"
+                (("STATIC_TEST") "SHARED_TEST"))
+              ;; Link Python library against shared library
+              (substitute* "src/python/CMakeLists.txt"
+                (("RingDecomposerLibStatic") "RingDecomposerLib"))
+              (substitute* "src/python/setup.py.in"
+                (("static_libs =.*") "static_libs = []\n")
+                (("shared_libs\\s*=.*")
+                 (string-append
+                  "shared_libs = ['RingDecomposerLib']"))
+                (("library_dirs\\s*=\\s*\\[\\]")
+                 "library_dirs = ['${CMAKE_BINARY_DIR}/src/RingDecomposerLib']")
+                (("extra_objects=.*")
+                 (string-append
+                  "extra_link_args=['-Wl,-rpath=" #$output "/lib'],\n")))))
+          (add-after 'build 'build-doc
+            (lambda _
+              ;; Disable redundant LaTeX documentation
+              (substitute* "../source/documentation/sphinx/conf.py"
+                (("^(subprocess.*latex|shutil).*") ""))
+              (substitute* "../source/documentation/doxygen.cfg"
+                (("GENERATE_LATEX.*YES") "GENERATE_LATEX = NO"))
+              ;; Build HTML documentation
+              (invoke "sphinx-build" "-b" "html"
+                      "../source/documentation/sphinx" "html")))
+          (add-after 'install 'install-doc
+            (lambda _
+              ;; Not reproducible
+              (delete-file-recursively "html/.doctrees")
+              (copy-recursively "html"
+                                (string-append #$output "/share/doc/"
+                                               #$name "-" #$version "/html"))))
+          (delete 'check)
+          (add-after 'install 'check
+            (assoc-ref %standard-phases 'check))
+          (add-before 'check 'set-pythonpath
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (add-installed-pythonpath inputs outputs))))))
+    (inputs (list python))
+    (native-inputs (list doxygen python python-cython python-sphinx))
+    (home-page "https://github.com/rareylab/RingDecomposerLib")
+    (synopsis "Library for calculating ring topology descriptions such as
+unique ring families")
+    (description "ringdecomposerlib is a library for the calculation of
+unique ring families, relevant cycles, the smallest set of smallest rings and
+other ring topology descriptions.")
+    (license license:bsd-3)))
-- 
2.37.0