Subject: [bug#58261] [PATCH 11/11] gnu: Add rdkit.

From: Liliana Marie Prikler <[email-masked]>
Date: Fri, 07 Oct 2022 17:29:26 +0200

Am Freitag, dem 07.10.2022 um 15:12 +0000 schrieb David Elsing:
> Liliana Marie Prikler <[email-masked]> writes:
> 
> > Am Montag, dem 03.10.2022 um 00:19 +0000 schrieb David Elsing:
> > > * gnu/packages/chemistry.scm (rdkit): New variable.
> > > ---
> > >  gnu/packages/chemistry.scm                    | 198
> > > ++++++++++++++++++
> > >  .../rdkit-cmake-external-dependencies.patch   | 102 +++++++++
> > >  2 files changed, 300 insertions(+)
> > >  create mode 100644 gnu/packages/patches/rdkit-cmake-external-
> > > dependencies.patch
> > > 
> > > diff --git a/gnu/packages/chemistry.scm
> > > b/gnu/packages/chemistry.scm
> > > index a39deff4bf..869cf264e3 100644
> > > --- a/gnu/packages/chemistry.scm
> > > +++ b/gnu/packages/chemistry.scm
> > > @@ -34,6 +34,7 @@ (define-module (gnu packages chemistry)
> > >    #:use-module (gnu packages algebra)
> > >    #:use-module (gnu packages autotools)
> > >    #:use-module (gnu packages backup)
> > > +  #:use-module (gnu packages base)
> > >    #:use-module (gnu packages bison)
> > >    #:use-module (gnu packages boost)
> > >    #:use-module (gnu packages check)
> > > @@ -41,10 +42,12 @@ (define-module (gnu packages chemistry)
> > >    #:use-module (gnu packages cpp)
> > >    #:use-module (gnu packages documentation)
> > >    #:use-module (gnu packages flex)
> > > +  #:use-module (gnu packages fonts)
> > >    #:use-module (gnu packages fontutils)
> > >    #:use-module (gnu packages gcc)
> > >    #:use-module (gnu packages gl)
> > >    #:use-module (gnu packages graphviz)
> > > +  #:use-module (gnu packages gtk)
> > >    #:use-module (gnu packages gv)
> > >    #:use-module (gnu packages image)
> > >    #:use-module (gnu packages maths)
> > > @@ -56,6 +59,7 @@ (define-module (gnu packages chemistry)
> > >    #:use-module (gnu packages qt)
> > >    #:use-module (gnu packages serialization)
> > >    #:use-module (gnu packages sphinx)
> > > +  #:use-module (gnu packages sqlite)
> > >    #:use-module (gnu packages stb)
> > >    #:use-module (gnu packages web)
> > >    #:use-module (gnu packages xml)
> > > @@ -899,3 +903,197 @@ (define-public yaehmop-tightbind
> > >      (description "@code{YAeHMOP} contains a program and library
> > > for
> > > performing
> > >  extended Hückel calculations.")
> > >      (license license:bsd-2)))
> > > +
> > > +(define-public rdkit
> > > +  (package
> > > +    (name "rdkit")
> > > +    (version "2022.03.5")
> > > +    (source (origin
> > > +              (method git-fetch)
> > > +              (uri (git-reference
> > > +                    (url "https://github.com/rdkit/rdkit")
> > > +                    (commit
> > > +                     (string-append
> > > +                      "Release_" (string-replace-substring
> > > version
> > > "." "_")))))
> > > +              (file-name (git-file-name name version))
> > > +              (sha256
> > > +               (base32
> > > +               
> > > "19idgilabh04cbr1qj6zgrgsfjm248mmfz6fsr0smrd68d0xnml9"))
> > > +              (patches
> > > +               (search-patches "rdkit-cmake-external-
> > > dependencies.patch"))
> > > +              (modules '((guix build utils)))
> > > +              (snippet
> > > +               #~(begin
> > > +                   ;; Remove pickle files (only used in tests),
> > > +                   ;; as they are compiled programs
> > > +                   (for-each
> > > +                    (lambda (name)
> > > +                      (display (string-append name "\n"))
> > > +                      (delete-file name))
> > > +                    (find-files "." "\\.pkl(\\.gz)?$"))
> > > +                   ;; Remove SQLite data files (can be
> > > generated)
> > > +                   (delete-file "Data/RDData.sqlt")
> > > +                   (delete-file "Data/RDTests.sqlt")
> > > +                   #t))))
> > > +    (build-system cmake-build-system)
> > > +    (native-inputs
> > > +     `(("bison" ,bison)
> > > +       ("boost" ,boost)
> > > +       ("catch2" ,catch2)
> > > +       ("eigen" ,eigen)
> > > +       ("flex" ,flex)
> > > +       ("freesasa" ,freesasa)
> > > +       ("pkg-config" ,pkg-config)
> > > +       ("rapidjson" ,rapidjson)
> > > +       ("tar" ,tar)
> > > +       ("avalontoolkit-src"
> > > +        ,(let ((version "1.2.0"))
> > > +           (origin
> > > +             (method url-fetch)
> > > +             (uri (string-append
> > > +                  
> > > "http://sourceforge.net/projects/avalontoolkit/files/"
> > > +                   "AvalonToolkit_" (substring version 0 3)
> > > "/AvalonToolkit_"
> > > +                   version ".source.tar"))
> > > +             (sha256
> > > +              (base32
> > > +              
> > > "0rnnyy6axs2da7aa4q6l30ldavbk49v6l22llj1adn74h1i67bpv"))
> > > +             (modules '((guix build utils) (ice-9 ftw) (srfi
> > > srfi-
> > > 26)))
> > > +             (snippet
> > > +              #~(begin
> > > +                  (chdir "..")
> > > +                  (delete-file-recursively "StandardFiles")
> > > +                  (delete-file-recursively
> > > "SourceDistribution/java")
> > > +                  #t)))))
> > > +       ("ringdecomposerlib-src"
> > > +        ,(let ((version "1.1.3"))
> > > +           (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")))))))
> > > +    (inputs
> > > +     (list cairo
> > > +           coordgenlibs
> > > +           font-comic-neue
> > > +           freetype
> > > +           inchi
> > > +           maeparser
> > > +           python
> > > +           sqlite
> > > +           yaehmop-tightbind))
> > > +    (propagated-inputs
> > > +     (list python-numpy python-cairocffi python-pillow))
> > > +    (arguments
> > > +     (list
> > > +      #: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)))
> > > +      #:configure-flags
> > > +      #~(list
> > > +         "-DRDK_BUILD_AVALON_SUPPORT=ON"
> > > +         "-DRDK_BUILD_CAIRO_SUPPORT=ON"
> > > +         "-DRDK_BUILD_CPP_TESTS=ON"
> > > +         "-DRDK_BUILD_FREESASA_SUPPORT=ON"
> > > +         "-DRDK_BUILD_INCHI_SUPPORT=ON"
> > > +         "-DRDK_BUILD_YAEHMOP_SUPPORT=ON"
> > > +         (string-append "-DCATCH_DIR="
> > > +                        #$(this-package-native-input "catch2")
> > > +                        "/include/catch2")
> > > +         "-DRDK_INSTALL_DEV_COMPONENT=ON"
> > > +         "-DRDK_INSTALL_INTREE=OFF"
> > > +         "-DRDK_INSTALL_STATIC_LIBS=OFF"
> > > +         (string-append
> > > +          "-DRDK_OPTIMIZE_POPCNT="
> > > +          #$(let ((system (or (%current-target-system)
> > > +                              (%current-system))))
> > > +              (cond
> > > +               ((string-prefix? "x86_64" system) "ON")
> > > +               ((string-prefix? "i686" system) "ON")
> > > +               (else "OFF"))))
> > > +         "-DRDK_USE_BOOST_IOSTREAMS=ON"
> > > +         "-DRDK_USE_FLEXBISON=ON")
> > > +      #:phases
> > > +      #~(modify-phases %standard-phases
> > > +          (add-after 'unpack 'copy-external-dependencies
> > > +            (lambda _
> > > +              (symlink
> > > +               (string-append
> > > +                #$(this-package-input "font-comic-neue")
> > > +                "/share/fonts/truetype/ComicNeue-Regular.ttf")
> > > +               "Data/Fonts/ComicNeue-Regular.ttf")
> > > +              (symlink #$(this-package-native-input "rapidjson")
> > > +                       "External/rapidjson-1.1.0")
> > > +              (invoke "tar" "xvf"
> > > +                      #$(this-package-native-input
> > > "avalontoolkit-
> > > src")
> > > +                      "-C" "External/AvalonTools")
> > > +              (symlink #$(this-package-native-input
> > > "ringdecomposerlib-src")
> > > +                      
> > > "External/RingFamilies/RingDecomposerLib")
> > > +              #t))
> > You might want to try unbundling those.  Either way, you should
> > find a
> > solution that doesn't depend on native-input labels.
> Ok, I unbundled them, but the package definitions became a bit long.
> :)  Do you think it is ok like that?
> > 
Long package definitions are not inherently bad (unless of course there
is an obviously less verbose way of writing them).  I'll take a look at
your v2 at a later time.

Cheers