From patchwork Thu Oct 13 21:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Elsing X-Patchwork-Id: 43386 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5C24127BBEA; Thu, 13 Oct 2022 22:06:57 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AD05C27BBE9 for ; Thu, 13 Oct 2022 22:06:56 +0100 (BST) Received: from localhost ([::1]:59610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj5Pr-0003xG-Qd for patchwork@mira.cbaines.net; Thu, 13 Oct 2022 17:06:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj5P7-00033u-4n for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oj5P4-0007VB-B6 for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oj5P4-0005nZ-5p for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58261] [PATCH v3 08/15] gnu: Add gemmi. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Oct 2022 21:06:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58261 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58261@debbugs.gnu.org Cc: David Elsing Received: via spool by 58261-submit@debbugs.gnu.org id=B58261.166569512022137 (code B ref 58261); Thu, 13 Oct 2022 21:06:06 +0000 Received: (at 58261) by debbugs.gnu.org; 13 Oct 2022 21:05:20 +0000 Received: from localhost ([127.0.0.1]:35157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj5OJ-0005ks-UN for submit@debbugs.gnu.org; Thu, 13 Oct 2022 17:05:20 -0400 Received: from mout01.posteo.de ([185.67.36.65]:35259) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj5Nz-0005ha-Kn for 58261@debbugs.gnu.org; Thu, 13 Oct 2022 17:05:00 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9EAAC240027 for <58261@debbugs.gnu.org>; Thu, 13 Oct 2022 23:04:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665695091; bh=Q2lEA2faRu8zy11QOt+w6OkaUhkUhPUw/mCXjD9ih30=; h=From:To:Cc:Subject:Date:From; b=D44FkDa8PtTEg2iUKTZq4vkgaS0klvnh/NovZIIbbO2NChupr76Y2/CM2MQEdk09X SFXZD4RYDBN+QsnI2PQBSw9k0oFjMdf1GXRxVeMwT93T/suJmZS0ntbR5c/pmjXlmU PYkTbaIWK9oAUmWv+qj4SrNI4cza/fVmht3fx3rod6OlbpmiW4rhIhJqyKOHl9CaZ2 XgFiYs480rLNmGehi+v8lf49R4mHMe4tLmcUElJO1pamAzdWSktEQBycITop1VpHcM 79dk6DnteOynjWTE5bg3L2KR7GEgY4vbnfGgqwMFOVZwb/+swrDuxTagJ8/lWbhf7I gfyXa/r8lV1BQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MpMTv1qnGz6tnd; Thu, 13 Oct 2022 23:04:51 +0200 (CEST) From: David Elsing Date: Thu, 13 Oct 2022 21:04:17 +0000 Message-Id: <20221013210424.993-9-david.elsing@posteo.net> In-Reply-To: <20221007152148.32591-1-david.elsing@posteo.net> References: <20221007152148.32591-1-david.elsing@posteo.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/chemistry.scm (gemmi): New variable. --- gnu/packages/chemistry.scm | 96 +++++++++++++++++++ .../patches/gemmi-fix-pegtl-usage.patch | 31 ++++++ .../patches/gemmi-fix-sajson-types.patch | 11 +++ 3 files changed, 138 insertions(+) create mode 100644 gnu/packages/patches/gemmi-fix-pegtl-usage.patch create mode 100644 gnu/packages/patches/gemmi-fix-sajson-types.patch diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm index 723b7ee8db..c6b8376248 100644 --- a/gnu/packages/chemistry.scm +++ b/gnu/packages/chemistry.scm @@ -589,3 +589,99 @@ (define-public sajson-for-gemmi ((#:phases phases) #~(modify-phases #$phases (delete 'build))))))) + +(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" + "gemmi-fix-pegtl-usage.patch")) + (modules '((guix build utils))) + (snippet + '(begin + (delete-file-recursively "include/gemmi/third_party") + (delete-file-recursively "third_party"))))) + (outputs '("out" "bin" "python")) + (build-system cmake-build-system) + (native-inputs + (list fast-float + optionparser + pegtl + pocketfft-cpp + pybind11 + sajson-for-gemmi + stb-sprintf + tinydir)) + (inputs (list python zlib)) + (arguments + (list + #:modules '((guix build cmake-build-system) + (guix build utils) + ((guix build python-build-system) + #:select (site-packages))) + #:imported-modules (append %cmake-build-system-modules + '((guix build python-build-system))) + #:configure-flags + #~(list "-DUSE_PYTHON=ON" + (string-append "-DPYTHON_INSTALL_DIR=" + (site-packages %build-inputs %outputs))) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'patch-includes + (lambda _ + (substitute* + (list + "include/gemmi/sprintf.hpp" + "include/gemmi/dirwalk.hpp" + "include/gemmi/cif.hpp" + "include/gemmi/json.hpp" + "python/gemmi.cpp" + "include/gemmi/atof.hpp" + "include/gemmi/numb.hpp" + "include/gemmi/fourier.hpp") + (("") "") + (("\"third_party/tinydir.h\"") "") + (("\"third_party/tao/pegtl.hpp\"") "") + (("\"third_party/sajson.h\"") "") + (("\"gemmi/third_party/tao/pegtl/parse_error.hpp\"") + "") + (("\"third_party/fast_float.h\"") + "") + (("\"third_party/pocketfft_hdronly.h\"") + "")))) + (add-after 'unpack 'change-bin-prefix + (lambda _ + (substitute* "CMakeLists.txt" + (("install\\(TARGETS program DESTINATION bin\\)") + (string-append + "install(TARGETS program DESTINATION " + #$output:bin "/bin)"))))) + (replace 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (with-directory-excursion "../source" + (setenv "PYTHONPATH" "../build") + (invoke "python3" "-m" "unittest" "discover" "-v" + "-s" "tests")))))))) + (home-page "https://gemmi.readthedocs.io/en/latest/") + (synopsis "Macromolecular crystallography library and utilities") + (description "GEMMI is a C++ library for macromolecular crystallography. +It can be used for working with +@enumerate +@item macromolecular models (content of PDB, PDBx/mmCIF and mmJSON files), +@item refinement restraints (CIF files), +@item reflection data (MTZ and mmCIF formats), +@item data on a 3D grid (electron density maps, masks, MRC/CCP4 format) +@item crystallographic symmetry. +@end enumerate") + (license license:mpl2.0))) diff --git a/gnu/packages/patches/gemmi-fix-pegtl-usage.patch b/gnu/packages/patches/gemmi-fix-pegtl-usage.patch new file mode 100644 index 0000000000..3667474847 --- /dev/null +++ b/gnu/packages/patches/gemmi-fix-pegtl-usage.patch @@ -0,0 +1,31 @@ +Use the definitions from (newer) upstream PEGTL. + +diff --git a/include/gemmi/cif.hpp b/include/gemmi/cif.hpp +index c7ffdb44..35d24210 100644 +--- a/include/gemmi/cif.hpp ++++ b/include/gemmi/cif.hpp +@@ -37,7 +37,6 @@ namespace pegtl = tao::pegtl; + namespace rules { + + template struct lookup_char { +- using analyze_t = pegtl::analysis::generic; + template static bool match(Input& in) { + if (!in.empty() && cif::char_table(in.peek_char()) == TableVal) { + if (TableVal == 2) // this set includes new-line +@@ -71,11 +70,11 @@ namespace rules { + struct ws_or_eof : pegtl::sor {}; + + // (b) Reserved words. +- struct str_data : TAOCPP_PEGTL_ISTRING("data_") {}; +- struct str_loop : TAOCPP_PEGTL_ISTRING("loop_") {}; +- struct str_global : TAOCPP_PEGTL_ISTRING("global_") {}; +- struct str_save : TAOCPP_PEGTL_ISTRING("save_") {}; +- struct str_stop : TAOCPP_PEGTL_ISTRING("stop_") {}; ++ struct str_data : TAO_PEGTL_ISTRING("data_") {}; ++ struct str_loop : TAO_PEGTL_ISTRING("loop_") {}; ++ struct str_global : TAO_PEGTL_ISTRING("global_") {}; ++ struct str_save : TAO_PEGTL_ISTRING("save_") {}; ++ struct str_stop : TAO_PEGTL_ISTRING("stop_") {}; + struct keyword : pegtl::sor {}; + diff --git a/gnu/packages/patches/gemmi-fix-sajson-types.patch b/gnu/packages/patches/gemmi-fix-sajson-types.patch new file mode 100644 index 0000000000..9633ddac8b --- /dev/null +++ b/gnu/packages/patches/gemmi-fix-sajson-types.patch @@ -0,0 +1,11 @@ +diff -ur a/include/gemmi/json.hpp b/include/gemmi/json.hpp +--- a/include/gemmi/json.hpp ++++ b/include/gemmi/json.hpp +@@ -38,6 +38,7 @@ + + inline std::string as_cif_value(const sajson::value& val) { + switch (val.get_type()) { ++ case sajson::TYPE_INTEGER: + case sajson::TYPE_DOUBLE: + return val.as_string(); + case sajson::TYPE_NULL: