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

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

Am Freitag, dem 07.10.2022 um 15:11 +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 (gemmi): New variable.
> > > ---
> > >  gnu/packages/chemistry.scm                    | 122 +++++++++++
> > >  .../patches/gemmi-fix-sajson-types.patch      |  11 +
> > >  .../sajson-for-gemmi-numbers-as-strings.patch | 195
> > > ++++++++++++++++++
> > >  3 files changed, 328 insertions(+)
> > >  create mode 100644 gnu/packages/patches/gemmi-fix-sajson-
> > > types.patch
> > >  create mode 100644 gnu/packages/patches/sajson-for-gemmi-
> > > numbers-as-
> > > strings.patch
> > > 
> > > diff --git a/gnu/packages/chemistry.scm
> > > b/gnu/packages/chemistry.scm
> > > index c517610fe8..f8fd85814f 100644
> > > --- a/gnu/packages/chemistry.scm
> > > +++ b/gnu/packages/chemistry.scm
> > > @@ -6,6 +6,7 @@
> > >  ;;; Copyright © 2020 Björn Höfling
> > > <[email-masked]>
> > >  ;;; Copyright © 2020 Vincent Legoll <[email-masked]>
> > >  ;;; Copyright © 2021 Ricardo Wurmus <[email-masked]>
> > > +;;; Copyright © 2022 David Elsing <[email-masked]>
> > >  ;;;
> > >  ;;; This file is part of GNU Guix.
> > >  ;;;
> > > @@ -23,6 +24,7 @@
> > >  ;;; along with GNU Guix.  If not, see
> > > <http://www.gnu.org/licenses/>.
> > >  
> > >  (define-module (gnu packages chemistry)
> > > +  #:use-module (guix gexp)
> > >    #:use-module (guix packages)
> > >    #:use-module (guix utils)
> > >    #:use-module ((guix licenses) #:prefix license:)
> > > @@ -35,6 +37,7 @@ (define-module (gnu packages chemistry)
> > >    #:use-module (gnu packages boost)
> > >    #:use-module (gnu packages check)
> > >    #:use-module (gnu packages compression)
> > > +  #:use-module (gnu packages cpp)
> > >    #:use-module (gnu packages documentation)
> > >    #:use-module (gnu packages fontutils)
> > >    #:use-module (gnu packages gl)
> > > @@ -50,8 +53,10 @@ (define-module (gnu packages chemistry)
> > >    #:use-module (gnu packages qt)
> > >    #:use-module (gnu packages serialization)
> > >    #:use-module (gnu packages sphinx)
> > > +  #:use-module (gnu packages stb)
> > >    #:use-module (gnu packages xml)
> > >    #:use-module (guix build-system cmake)
> > > +  #:use-module (guix build-system copy)
> > >    #:use-module (guix build-system gnu)
> > >    #:use-module (guix build-system python))
> > >  
> > > @@ -566,3 +571,120 @@ (define-public python-pymol
> > >  used to prepare publication-quality figures, to share
> > > interactive
> > > results with
> > >  your colleagues, or to generate pre-rendered animations.")
> > >      (license license:bsd-3)))
> > > +
> > > +(define sajson-for-gemmi
> > > +  (package/inherit sajson
> > > +    (name "sajson-for-gemmi")
> > > +    (source (origin
> > > +              (inherit (package-source sajson))
> > > +              (patches (cons
> > > +                        (search-patch
> > > +                         "sajson-for-gemmi-numbers-as-
> > > strings.patch")
> > > +                        (origin-patches (package-source
> > > sajson))))))
> > > +    (build-system copy-build-system)
> > > +    (arguments
> > > +     (list
> > > +      #:install-plan
> > > +      #~'(("include/sajson.h" "include/")
> > > +          ("include/sajson_ostream.h" "include/"))))))
> > These are technically two packages; therefore two patches.
> > You should reuse as much as you can from sajson.  Since this patch
> > is
> > likely to break tests, you might use an appropriately annotated
> > #:tests? #f to convey this information.
> > 
> You mean to copy the GCC10 patch?
> Building the tests also fails, but the rest works. :)
> Should I put it in a separate commit?
One commit for sajson-for-gemmi, one commit for gemmi.
"Reuse as much as possible" particularly means reuse the build system,
but highlight that #:tests? need to be set to #f.  (Also, use
substitute-keyword-arguments to actually set it to #f.)

> > > +(define-public gemmi
> > > +  (package
> > > +    (name "gemmi")
> > > +    (version "0.5.7")
> > > +    (source (origin
> > > +              (method git-fetch)
> > > +              (uri (git-reference
> > > +                    (url
> > > "https://github.com/project-gemmi/gemmi")
> > > +                    (commit (string-append "v" version))))
> > > +              (file-name (git-file-name name version))
> > > +              (sha256
> > > +               (base32
> > > +               
> > > "00km5q726bslrw7xbfwb3f3mrsk19qbimfnl3hvr4wi1y3z8i18a"))
> > > +              (patches
> > > +               (search-patches "gemmi-fix-sajson-types.patch"))
> > > +              (modules '((guix build utils)))
> > > +              (snippet
> > > +               '(begin
> > > +                  (delete-file-recursively
> > > "include/gemmi/third_party")
> > > +                  (delete-file-recursively "third_party")
> > > +                  #t))))
> > > +    (build-system cmake-build-system)
> > > +    (native-inputs (list optionparser pybind11))
> > > +    (propagated-inputs
> > > +     (list fast-float
> > > +           pocketfft
> > > +           sajson-for-gemmi
> > > +           stb-sprintf
> > > +           pegtl
> > > +           tinydir))
> > Refrain from propagating inputs.
> Ah ok.
> > > +    (inputs (list zlib python))
> > > +    (outputs '("out" "bin" "python"))
> > > +    (arguments
> > The usual sequence is outputs, build-system, arguments, *inputs.
> Is there also a usual sequence for the *inputs?
IIRC it's plain, propagated, native.

Cheers