From: David Elsing <david.elsing@posteo.net>
To: 68790@debbugs.gnu.org
Cc: David Elsing <david.elsing@posteo.net>
Subject: [bug#68790] [PATCH 7/9] gnu: avalon-toolkit: Update to 2.0.5a.
Date: Sun, 28 Jan 2024 23:02:00 +0000 [thread overview]
Message-ID: <20240128230215.1389-7-david.elsing@posteo.net> (raw)
In-Reply-To: <20240128225919.795-2-david.elsing@posteo.net>
The bug freeing static memory and the makefile have been improved upstream, so
we don't have to work around them anymore. Now, two static libraries are built
instead.
* gnu/packages/chemistry.scm (avalon-toolkit): Update to 2.0.5a.
[source]: Switch to git reference from GitHub. Adjust snippet. Add patch from
the RDKit fork.
[arguments]: Remove 'dont-free-static-memory phase. Use provided
makefile. Adjust 'install phase.
* gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
gnu/local.mk | 2 +
gnu/packages/chemistry.scm | 131 ++++++++----------
.../patches/avalon-toolkit-rdkit-fixes.patch | 110 +++++++++++++++
3 files changed, 166 insertions(+), 77 deletions(-)
create mode 100644 gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index ab63bd5881..b5d61eb4dd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -63,6 +63,7 @@
# Copyright © 2023 gemmaro <gemmaro.dev@gmail.com>
# Copyright © 2023 Herman Rimm <herman@rimm.ee>
# Copyright © 2023 Troy Figiel <troy@troyfigiel.com>
+# Copyright © 2024 David Elsing <david.elsing@posteo.net>
#
# This file is part of GNU Guix.
#
@@ -952,6 +953,7 @@ dist_patch_DATA = \
%D%/packages/patches/audiofile-function-signature.patch \
%D%/packages/patches/automake-skip-amhello-tests.patch \
%D%/packages/patches/avahi-localstatedir.patch \
+ %D%/packages/patches/avalon-toolkit-rdkit-fixes.patch \
%D%/packages/patches/avidemux-install-to-lib.patch \
%D%/packages/patches/awesome-reproducible-png.patch \
%D%/packages/patches/awesome-4.3-fno-common.patch \
diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm
index 4a9dd97c5b..5e19bdf182 100644
--- a/gnu/packages/chemistry.scm
+++ b/gnu/packages/chemistry.scm
@@ -917,90 +917,67 @@ (define-public yaehmop
(define-public avalon-toolkit
(package
(name "avalon-toolkit")
- (version "1.2.0")
- (source
- (origin
- (method url-fetch)
- (uri (string-append
- "mirror://sourceforge/avalontoolkit/"
- "AvalonToolkit_" (substring version 0 3) "/AvalonToolkit_"
- version ".source.tar"))
- (sha256
- (base32
- "0rnnyy6axs2da7aa4q6l30ldavbk49v6l22llj1adn74h1i67bpv"))
- (modules '((guix build utils) (ice-9 ftw)))
- (snippet
- #~(begin
- (delete-file-recursively "../SourceDistribution/java")))))
+ (version "2.0.5a")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/rohdebe1/ava-formake")
+ (commit (string-append "AvalonToolkit_" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1mfg40y5xc17sm59zdfc5sk22n9zm5zk0z1aw47chvl6hp465szk"))
+ (patches
+ (search-patches "avalon-toolkit-rdkit-fixes.patch"))
+ (modules '((guix build utils) (ice-9 ftw)))
+ (snippet
+ #~(begin
+ (delete-file-recursively "src/main/java")
+ (delete-file-recursively "src/test/target")))))
(build-system gnu-build-system)
(arguments
(list
- ;; There are no intended tests
+ ;; There is only one test, which is missing a file
#:tests? #f
#:phases
- #~(let ((programs '("canonizer" "matchtest" "sketch" "smi2mol" "struchk")))
- (modify-phases %standard-phases
- (add-after 'unpack 'chdir
- (lambda _ (chdir "common")))
- (delete 'configure)
- (add-before 'build 'dont-free-static-memory
- (lambda _
- (substitute* "reaccsio.c"
- (("MyFree\\(.*tempdir\\)" m)
- (string-append "/* freeing memory from getenv is bad */"
- "// " m)))))
- ;; The makefile has incorrect compiler flags and is missing some
- ;; object files, so we build it ourselves.
- (replace 'build
- (lambda _
- (for-each
- (lambda (part)
- (format #t "Compiling ~a.c ~~> ~a.o~%" part part)
- (invoke #$(cc-for-target) "-c" "-fPIC" "-O2"
- (string-append part ".c")
- "-o" (string-append part ".o")))
- (list "aacheck" "casutils" "denormal" "depictutil"
- "didepict" "fixcharges" "forio" "geometry"
- "graph" "hashcode" "layout" "local" "pattern"
- "perceive" "reaccsio" "rtutils" "set" "shortcut"
- "sketch" "ssmatch" "stereo" "symbol_lists"
- "symboltable" "utilities"))
- (display "Building libavalontoolkit.so\n")
- (apply invoke "gcc" "-fPIC" "-shared" "-lm"
- "-o" "libavalontoolkit.so" "canonizer.c" "smi2mol.c"
- "struchk.c" "patclean.c" (find-files "." "\\.o$"))
- ;; patclean is not built here as there is an undeclared
- ;; variable in main().
- (for-each
- (lambda (program)
- (display (string-append "Building " program "\n"))
- (invoke "gcc" "-L." "-lavalontoolkit" "-lm" "-O2"
- (string-append "-Wl,-rpath=" #$output "/lib")
- "-DMAIN" (string-append program ".c") "-o" program))
- programs)))
- (replace 'install
- (lambda _
- ;; Executables
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda* (#:key parallel-build? #:allow-other-keys)
+ (mkdir "build")
+ (mkdir-p "target/executables")
+ (mkdir-p "target/libraries")
+ (invoke "make" "programs" "-j"
+ (if parallel-build?
+ (number->string (parallel-job-count))
+ "1"))))
+ (replace 'install
+ (lambda _
+ ;; Executables
+ (let ((programs '("canonizer" "matchtest" "smi2mol" "struchk")))
(for-each
(lambda (program)
- (install-file program (string-append #$output "/bin")))
- programs)
- (for-each
- (lambda (name)
- (symlink (string-append #$output "/bin/smi2mol")
- (string-append #$output "/bin/" name)))
- '("mol2smi" "rdf2smi" "mol2tbl" "mol2sma" "smi2rdf"))
- ;; Library
- (install-file "libavalontoolkit.so"
- (string-append #$output "/lib"))
- (for-each
- (lambda (file)
- (install-file file (string-append #$output
- "/include/avalontoolkit")))
- (find-files "." "\\.h$"))
- (install-file "../license.txt"
- (string-append #$output "/share/doc/"
- #$name "-" #$version "/"))))))))
+ (install-file (string-append "target/executables/" program)
+ (string-append #$output "/bin")))
+ programs))
+ (for-each
+ (lambda (name)
+ (symlink (string-append #$output "/bin/smi2mol")
+ (string-append #$output "/bin/" name)))
+ '("mol2smi" "rdf2smi" "mol2tbl" "mol2sma" "smi2rdf"))
+ ;; Library
+ (install-file "target/libraries/libavalon_tools.a"
+ (string-append #$output "/lib"))
+ (install-file "target/libraries/libavalon4rdkit.a"
+ (string-append #$output "/lib"))
+ (for-each
+ (lambda (file)
+ (install-file file (string-append #$output
+ "/include/avalontoolkit")))
+ (find-files "src/main/C/include" "\\.h$"))
+ (install-file "license.txt"
+ (string-append #$output "/share/doc/"
+ #$name "-" #$version "/")))))))
(home-page "https://sourceforge.net/projects/avalontoolkit/")
(synopsis "Tools for SMILES and MOL files and for structure fingerprinting")
(description "This package contains a library and programs for
diff --git a/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch b/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch
new file mode 100644
index 0000000000..c93a9869ed
--- /dev/null
+++ b/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch
@@ -0,0 +1,110 @@
+Patches taken from the rdkit fork at this commit (there version
+AvalonToolkit_2.0.6-pre.2):
+https://github.com/rdkit/ava-formake/commit/d05bee0382b8f4696b2b4b05b0038fb7d559520a
+
+diff -ur a/src/main/C/common/reaccsio.c b/src/main/C/common/reaccsio.c
+--- a/src/main/C/common/reaccsio.c
++++ b/src/main/C/common/reaccsio.c
+@@ -322,34 +322,49 @@
+ fprintf(fp,"\n");
+ }
+
++#define MAX_BONDLINE_FIELDS 7
++#define BONDLINE_FIELD_LEN 3
++
+ int ReadREACCSBond(Fortran_FILE *fp, struct reaccs_bond_t *bp)
+ {
+- int nitems, i;
+- char buffer[MAX_BUFFER+1];
++ int nitems, i, j, k;
++ int bond_line_len, n_chars, pos;
++ int *ptrarray[MAX_BONDLINE_FIELDS];
++ char c;
++ char buffer[BONDLINE_FIELD_LEN+1];
+
+ if (fp->status != FORTRAN_NORMAL) return(fp->status);
+
+- strncpy(buffer,fp->buffer,MAX_BUFFER);
+- /* zero pad only atom numbers! */
+- for (i=0; i<6; i++) if (buffer[i] == ' ') buffer[i] = '0';
+-
+ bp->stereo_symbol = 0;
+ bp->dummy = 0;
+ bp->topography = 0;
+ bp->reaction_mark = NONE;
+- // make sure spaces are interpreted the Fortran-way
+- for (i=9; i<strlen(buffer) && i<21; i+=3)
+- {
+- if ((i+1)<strlen(buffer) && buffer[i+1]==' ') buffer[i+1] = '0';
+- if ((i+2)<strlen(buffer) && buffer[i+2]==' ') buffer[i+2] = '0';
++ ptrarray[0] = &bp->atoms[0];
++ ptrarray[1] = &bp->atoms[1];
++ ptrarray[2] = &bp->bond_type;
++ ptrarray[3] = &bp->stereo_symbol;
++ ptrarray[4] = &bp->dummy;
++ ptrarray[5] = &bp->topography;
++ ptrarray[6] = &bp->reaction_mark;
++ bond_line_len = strlen(fp->buffer);
++ nitems = bond_line_len ? (bond_line_len - 1) / BONDLINE_FIELD_LEN + 1 : 0;
++ if (nitems > MAX_BONDLINE_FIELDS)
++ nitems = MAX_BONDLINE_FIELDS;
++ for (i = 0; i < nitems; ++i)
++ {
++ pos = i * BONDLINE_FIELD_LEN;
++ memset(buffer, 0, BONDLINE_FIELD_LEN + 1);
++ n_chars = bond_line_len - pos;
++ if (n_chars > BONDLINE_FIELD_LEN)
++ n_chars = BONDLINE_FIELD_LEN;
++ for (j = 0, k = 0; j < n_chars; ++j)
++ {
++ c = fp->buffer[pos + j];
++ if (c != ' ')
++ buffer[k++] = c;
++ }
++ sscanf(buffer, "%3d", ptrarray[i]);
+ }
+- nitems = sscanf(buffer,
+- "%3d%3d%3d%3d%3d%3d%3d",
+- &bp->atoms[0], &bp->atoms[1],
+- &bp->bond_type, &bp->stereo_symbol,
+- &bp->dummy,
+- &bp->topography, &bp->reaction_mark);
+-
+ if (nitems >= 3)
+ {
+ GetBuffer(fp);
+@@ -1582,6 +1597,8 @@
+
+ PrintREACCSMolecule(fp, mp,"");
+
++ fputc('\0', fp);
++ fflush(fp);
+ rewind(fp);
+
+ MolStr = _ReadFile(fp);
+diff -ur a/src/main/C/programs/struchk.c b/src/main/C/programs/struchk.c
+--- a/src/main/C/programs/struchk.c
++++ b/src/main/C/programs/struchk.c
+@@ -1581,6 +1581,22 @@
+
+ if ((result & SIZE_CHECK_FAILED) == 0)
+ {
++ for (i = 0; i < mp->n_bonds; ++i) {
++ for (j = 0; j < 2; ++j) {
++ if (mp->bond_array[i].atoms[j] < 1 || mp->bond_array[i].atoms[j] > mp->n_atoms)
++ {
++ snprintf(msg_buffer, MAXMSG,
++ "%10s : illegal atom # (%d, max allowed is %d) in bond %d",
++ mp->name, mp->bond_array[i].atoms[j], mp->n_atoms, i + 1);
++ AddMsgToList(msg_buffer);
++ result |= SIZE_CHECK_FAILED;
++ }
++ }
++ }
++ }
++
++ if ((result & SIZE_CHECK_FAILED) == 0)
++ {
+ if (convert_atom_texts)
+ {
+ tmp = ConvertAtomAliases(mp);
--
2.41.0
next prev parent reply other threads:[~2024-01-28 23:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-28 22:59 [bug#68790] [PATCH 0/9] Update rdkit and its dependencies David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 1/9] gnu: tinydir: Update to 1.2.6 David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 2/9] gnu: fast-float: Update to 6.0.0 David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 3/9] gnu: gemmi: Update to 0.6.4 David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 4/9] gnu: maeparser: Update to 1.3.1 David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 5/9] gnu: coordgenlibs: Update to 3.0.2 David Elsing
2024-01-28 23:01 ` [bug#68790] [PATCH 6/9] gnu: yaehmop: Update to 2023.03.1 David Elsing
2024-01-28 23:02 ` David Elsing [this message]
2024-01-28 23:02 ` [bug#68790] [PATCH 8/9] gnu: freesasa: Fix memerr tests David Elsing
2024-01-28 23:02 ` [bug#68790] [PATCH 9/9] gnu: rdkit: Update to 2023.09.4 David Elsing
2024-02-13 12:18 ` [bug#68790] [PATCH 0/9] Update rdkit and its dependencies Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240128230215.1389-7-david.elsing@posteo.net \
--to=david.elsing@posteo.net \
--cc=68790@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.