[PATCH 0/5] Update clingo and add telingo

  • Done
  • quality assurance status badge
Details
One participant
  • Liliana Marie Prikler
Owner
unassigned
Submitted by
Liliana Marie Prikler
Severity
normal
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:54
(address . guix-patches@gnu.org)
dc4bd56c84e4656c5603fd66eeff80dbdf3de487.camel@gmail.com
Hi Guix,

ever since clasp received a relatively minor upgrade [1], our clingo package
has been failing to build. This appears to be the fault of potassco not doing
semver correctly, but it'd still be nice to fix this.

Following is a series that updates clingo and also adds telingo -- a temporal
extension to clingo.

Cheers


Liliana Marie Prikler (5):
gnu: Add catch2-3.1.
gnu: clingo: Update to 5.6.2.
gnu: clingo: Use G-Expressions.
gnu: Add python-clingo.
gnu: Add python-telingo.

gnu/local.mk | 1 +
gnu/packages/check.scm | 79 ++++++++++
gnu/packages/maths.scm | 146 ++++++++++++------
.../python-telingo-fix-comparison.patch | 19 +++
4 files changed, 199 insertions(+), 46 deletions(-)
create mode 100644 gnu/packages/patches/python-telingo-fix-comparison.patch


base-commit: b94724e8b2102be0fe9d19e9dfe44d6f7101bd4b
--
2.38.1
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:33
[PATCH 2/5] gnu: clingo: Update to 5.6.2.
(address . 59896@debbugs.gnu.org)
a1b183dd1cdaf8aa085e438f0f1ef027f173068f.camel@gmail.com
* gnu/packages/maths.scm (clingo): Update to 5.6.2.
[source]: Unbundle clasp and catch.
[arguments]<#:configure-flags>: Add “-DCLINGO_USE_LOCAL_CLASP=off” and
“-DCLINGO_USE_LOCAL_CATCH=off”.
[inputs]: Add catch2-3.1.
[native-inputs]: Add pkg-config.
---
gnu/packages/maths.scm | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

Toggle diff (57 lines)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index c0bc07977b..6a55284308 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -2625,27 +2625,30 @@ (define-public clasp
(define-public clingo
(package
(name "clingo")
- (version "5.5.0")
+ (version "5.6.2")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/potassco/clingo")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
+ (modules '((guix build utils)))
+ (snippet
+ #~(begin
+ (delete-file-recursively "clasp")
+ ;; TODO: Unvendor other third-party stuff
+ (delete-file-recursively "third_party/catch")))
(sha256
(base32
- "0rfjwkcwm0mmf3r4i7asyjwb6cia4i7px7fn2kdbi9j85qvas4pb"))))
+ "19s59ndcm2yj0kxlikfxnx2bmp6b7n31wq1zvwc7hyk37rqarwys"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags `("-DCLINGO_BUILD_TESTS=on"
"-DCLINGO_INSTALL_LIB=on"
"-DCLINGO_BUILD_STATIC=off"
"-DCLINGO_BUILD_SHARED=on"
- ;; XXX: Clingo requries private headers and
- ;; sources from clasp
- ,(string-append
- "-DCLASP_SOURCE_DIR="
- (assoc-ref %build-inputs "clasp-src")))
+ "-DCLINGO_USE_LOCAL_CLASP=off"
+ "-DCLINGO_USE_LOCAL_CATCH=off")
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-cmake
@@ -2677,10 +2680,8 @@ (define-public clingo
"unpool-ast-v2" "parse_term"
"propagator" "propgator-sequence-mining"
"symbol" "visitor"))))))))))
- (inputs
- (list clasp libpotassco))
- (native-inputs
- `(("clasp-src" ,(package-source clasp))))
+ (inputs (list catch2-3.1 clasp libpotassco))
+ (native-inputs (list pkg-config))
(home-page "https://potassco.org/")
(synopsis "Grounder and solver for logic programs")
(description "Clingo computes answer sets for a given logic program.")
--
2.38.1
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:47
[PATCH 3/5] gnu: clingo: Use G-Expressions.
(address . 59896@debbugs.gnu.org)
e7b9279984c2b34eecf62edb56746258ba5ef028.camel@gmail.com
* gnu/packages/maths.scm (clingo)[arguments]: Convert to list of G-Expressions.
---
gnu/packages/maths.scm | 75 +++++++++++++++++++++---------------------
1 file changed, 38 insertions(+), 37 deletions(-)

Toggle diff (88 lines)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 6a55284308..2215be9dad 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -2643,43 +2643,44 @@ (define-public clingo
"19s59ndcm2yj0kxlikfxnx2bmp6b7n31wq1zvwc7hyk37rqarwys"))))
(build-system cmake-build-system)
(arguments
- `(#:configure-flags `("-DCLINGO_BUILD_TESTS=on"
- "-DCLINGO_INSTALL_LIB=on"
- "-DCLINGO_BUILD_STATIC=off"
- "-DCLINGO_BUILD_SHARED=on"
- "-DCLINGO_USE_LOCAL_CLASP=off"
- "-DCLINGO_USE_LOCAL_CATCH=off")
- #:phases
- (modify-phases %standard-phases
- (add-after 'unpack 'patch-cmake
- (lambda _
- (substitute* "CMakeLists.txt"
- (("add_subdirectory\\(clasp\\)")
- "find_package(clasp REQUIRED)"))
- (substitute* "libclingo/CMakeLists.txt"
- (("\"cmake/Clingo\"") "\"cmake/clingo\"")
- (("ClingoConfig\\.cmake") "clingo-config.cmake")
- (("ClingoConfigVersion\\.cmake")
- "clingo-config-version.cmake"))
- (substitute* "cmake/ClingoConfig.cmake.in"
- (("find_package\\(Clasp") "find_package(clasp"))
- (rename-file "cmake/ClingoConfig.cmake.in"
- "cmake/clingo-config.cmake.in")))
- (add-after 'unpack 'skip-failing-tests
- (lambda _
- (with-directory-excursion "libclingo/tests"
- (substitute* "CMakeLists.txt"
- (("COMMAND test_clingo" all)
- (string-append all
- " -f "
- "\"${CMAKE_CURRENT_SOURCE_DIR}/good.txt\"")))
- (call-with-output-file "good.txt"
- (lambda (port)
- (for-each (lambda (test) (format port "~s~%" test))
- '("parse-ast-v2" "add-ast-v2" "build-ast-v2"
- "unpool-ast-v2" "parse_term"
- "propagator" "propgator-sequence-mining"
- "symbol" "visitor"))))))))))
+ (list
+ #:configure-flags #~`("-DCLINGO_BUILD_TESTS=on"
+ "-DCLINGO_INSTALL_LIB=on"
+ "-DCLINGO_BUILD_STATIC=off"
+ "-DCLINGO_BUILD_SHARED=on"
+ "-DCLINGO_USE_LOCAL_CLASP=off"
+ "-DCLINGO_USE_LOCAL_CATCH=off")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-cmake
+ (lambda _
+ (substitute* "CMakeLists.txt"
+ (("add_subdirectory\\(clasp\\)")
+ "find_package(clasp REQUIRED)"))
+ (substitute* "libclingo/CMakeLists.txt"
+ (("\"cmake/Clingo\"") "\"cmake/clingo\"")
+ (("ClingoConfig\\.cmake") "clingo-config.cmake")
+ (("ClingoConfigVersion\\.cmake")
+ "clingo-config-version.cmake"))
+ (substitute* "cmake/ClingoConfig.cmake.in"
+ (("find_package\\(Clasp") "find_package(clasp"))
+ (rename-file "cmake/ClingoConfig.cmake.in"
+ "cmake/clingo-config.cmake.in")))
+ (add-after 'unpack 'skip-failing-tests
+ (lambda _
+ (with-directory-excursion "libclingo/tests"
+ (substitute* "CMakeLists.txt"
+ (("COMMAND test_clingo" all)
+ (string-append all
+ " -f "
+ "\"${CMAKE_CURRENT_SOURCE_DIR}/good.txt\"")))
+ (call-with-output-file "good.txt"
+ (lambda (port)
+ (for-each (lambda (test) (format port "~s~%" test))
+ '("parse-ast-v2" "add-ast-v2" "build-ast-v2"
+ "unpool-ast-v2" "parse_term"
+ "propagator" "propgator-sequence-mining"
+ "symbol" "visitor"))))))))))
(inputs (list catch2-3.1 clasp libpotassco))
(native-inputs (list pkg-config))
(home-page "https://potassco.org/")
--
2.38.1
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:31
[PATCH 1/5] gnu: Add catch2-3.1.
(address . 59896@debbugs.gnu.org)
c379bfcab3215a24e775ac3fc136d6e10360e9cb.camel@gmail.com
* gnu/packages/check.scm (catch2-3.1): New variable.
---
gnu/packages/check.scm | 79 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)

Toggle diff (92 lines)
diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index c900a055d5..af48ae91be 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -580,6 +580,85 @@ (define-public cbehave
pattern.")
(license license:apsl2))))
+(define-public catch2-3.1
+ (package
+ (name "catch2")
+ (version "3.1.1")
+ (home-page "https://github.com/catchorg/Catch2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/catchorg/Catch2")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1qnr5b3zq8brh43f924rgnw5gmmjf9ax7kbq2crz1mlwgmdymxlp"))))
+ (outputs (list "out" "static"))
+ (build-system meson-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-meson
+ (lambda _
+ (substitute* "src/catch2/meson.build"
+ (("static_library") "both_libraries"))))
+ (add-after 'install 'install-cmake-config
+ (lambda* (#:key outputs #:allow-other-keys)
+ (define prefix (string-append (assoc-ref outputs "out")
+ "/lib/cmake/Catch2/"))
+ (mkdir-p prefix)
+ (call-with-output-file (string-append
+ prefix
+ "catch2-config-version.cmake")
+ (lambda (port)
+ (format
+ port
+ "set(PACKAGE_VERSION ~s)~@
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)~@
+ set(PACKAGE_VERSION_EXACT TRUE)~@
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)~@
+ elseif(PACKAGE_FIND_VERSION VERSION_LESS_EQUAL ~
+ PACKAGE_VERSION)~@
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)~@
+ else()~@
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)~@
+ endif()"
+ #$version)))
+ (call-with-output-file (string-append prefix
+ "catch2-config.cmake")
+ (lambda (port)
+ (format
+ port
+ "include(FindPkgConfig)~@
+ pkg_check_modules(CATCH2 IMPORTED_TARGET GLOBAL catch2)~@
+ pkg_check_modules(CATCH2MAIN ~
+ IMPORTED_TARGET GLOBAL ~
+ catch2 catch2-with-main)~@
+ if(CATCH2_FOUND)~@
+ add_library(Catch2::Catch2 ALIAS PkgConfig::CATCH2)~@
+ endif()~@
+ if(CATCH2MAIN_FOUND)~@
+ add_library(Catch2::Catch2WithMain ~
+ ALIAS PkgConfig::CATCH2MAIN)~@
+ endif()")))))
+ (add-after 'install 'move-static-libraries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (static (assoc-ref outputs "static")))
+ (for-each
+ (lambda (file)
+ (install-file file (string-append static "/lib"))
+ (delete-file file))
+ (find-files (string-append out "/lib")
+ "\\.a$"))))))))
+ (inputs (list python-wrapper))
+ (synopsis "Automated test framework for C++ and Objective-C")
+ (description "Catch2 stands for C++ Automated Test Cases in Headers and is
+a multi-paradigm automated test framework for C++ and Objective-C.")
+ (license license:boost1.0)))
+
(define-public cmdtest
(package
(name "cmdtest")
--
2.38.1
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:49
[PATCH 5/5] gnu: Add python-telingo.
(address . 59896@debbugs.gnu.org)
1da46d86f9d5850afe7f8f14070a3c025dbae3f7.camel@gmail.com
* gnu/packages/patches/python-telingo-fix-comparison.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/maths.scm (python-telingo): New variable.
---
gnu/local.mk | 1 +
gnu/packages/maths.scm | 23 +++++++++++++++++++
.../python-telingo-fix-comparison.patch | 19 +++++++++++++++
3 files changed, 43 insertions(+)
create mode 100644 gnu/packages/patches/python-telingo-fix-comparison.patch

Toggle diff (80 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 3329801fa6..0ada842407 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1644,6 +1644,7 @@ dist_patch_DATA = \
%D%/packages/patches/python-louvain-fix-test.patch \
%D%/packages/patches/python-random2-getrandbits-test.patch \
%D%/packages/patches/python-poppler-qt5-fix-build.patch \
+ %D%/packages/patches/python-telingo-fix-comparison.patch \
%D%/packages/patches/python-w3lib-fix-test-failure.patch \
%D%/packages/patches/sdcc-disable-non-free-code.patch \
%D%/packages/patches/sdl-pango-api_additions.patch \
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 4f057820f0..23c886dfdb 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -92,6 +92,7 @@ (define-module (gnu packages maths)
#:use-module (guix build-system ocaml)
#:use-module (guix build-system perl)
#:use-module (guix build-system python)
+ #:use-module (guix build-system pyproject)
#:use-module (guix build-system ruby)
#:use-module (gnu packages algebra)
#:use-module (gnu packages audio)
@@ -2717,6 +2718,28 @@ (define-public python-clingo
making it so that you can write @acronym{ASPs, Answer Set Programs} through
Python code.")))
+(define-public python-telingo
+ (package
+ (name "python-telingo")
+ (version "2.1.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/potassco/telingo")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "python-telingo-fix-comparison.patch"))
+ (sha256
+ (base32
+ "0g3khxfdzc2hc7dkiyyqhb399h6h21m5wkp6wy8w71n0m32fiy53"))))
+ (build-system pyproject-build-system)
+ (propagated-inputs (list python-clingo))
+ (home-page "https://potassco.org/")
+ (synopsis "Solve dynamic temporal logic programs")
+ (description "This package provides a system to solve dynamic temporal
+logic programs based on clingo.")
+ (license license:expat)))
+
(define-public ceres
(package
(name "ceres-solver")
diff --git a/gnu/packages/patches/python-telingo-fix-comparison.patch b/gnu/packages/patches/python-telingo-fix-comparison.patch
new file mode 100644
index 0000000000..6d05048dcb
--- /dev/null
+++ b/gnu/packages/patches/python-telingo-fix-comparison.patch
@@ -0,0 +1,19 @@
+Index: source/telingo/transformers/head.py
+===================================================================
+--- source.orig/telingo/transformers/head.py
++++ source/telingo/transformers/head.py
+@@ -564,10 +564,12 @@ class HeadTransformer:
+ cond = []
+ diff = _ast.BinaryOperation(loc, _ast.BinaryOperator.Minus, param, shift)
+ if lhs.ast_type != _ast.ASTType.SymbolicTerm or lhs.symbol.type != _clingo.SymbolType.Number or lhs.symbol.number > 0:
+- cond.append(_ast.Literal(loc, _ast.Sign.NoSign, _ast.Comparison(_ast.ComparisonOperator.LessEqual, lhs, diff)))
++ cond.append(_ast.Literal(loc, _ast.Sign.NoSign,
++ _ast.Comparison(lhs, [_ast.Guard(_ast.ComparisonOperator.LessEqual, diff)])))
+
+ if rhs.ast_type != _ast.ASTType.SymbolicTerm or rhs.symbol.type != _clingo.SymbolType.Supremum:
+- cond.append(_ast.Literal(loc, _ast.Sign.NoSign, _ast.Comparison(_ast.ComparisonOperator.LessEqual, diff, rhs)))
++ cond.append(_ast.Literal(loc, _ast.Sign.NoSign,
++ _ast.Comparison(diff, [_ast.Guard(_ast.ComparisonOperator.LessEqual, rhs)])))
+
+ elems.extend([_ast.ConditionalLiteral(loc, _ast.Literal(loc, _ast.Sign.NoSign, head), cond) for head in heads])
+
--
2.38.1
L
L
Liliana Marie Prikler wrote on 8 Dec 2022 09:48
[PATCH 4/5] gnu: Add python-clingo.
(address . 59896@debbugs.gnu.org)
118732f45017240e251ddcc41b307d8326a4d272.camel@gmail.com
* gnu/packages/maths.scm (python-clingo): New variable.
---
gnu/packages/maths.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (49 lines)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 2215be9dad..4f057820f0 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -126,6 +126,7 @@ (define-module (gnu packages maths)
#:use-module (gnu packages image)
#:use-module (gnu packages java)
#:use-module (gnu packages less)
+ #:use-module (gnu packages libffi)
#:use-module (gnu packages lisp)
#:use-module (gnu packages linux)
#:use-module (gnu packages llvm)
@@ -2688,6 +2689,34 @@ (define-public clingo
(description "Clingo computes answer sets for a given logic program.")
(license license:expat)))
+(define-public python-clingo
+ (package
+ (inherit clingo)
+ (name "python-clingo")
+ (arguments
+ (substitute-keyword-arguments (package-arguments clingo)
+ ((#:configure-flags flags #~'())
+ #~(cons* "-DCLINGO_BUILD_WITH_PYTHON=pip"
+ "-DCLINGO_USE_LIB=yes"
+ #$flags))
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'unpack 'fix-failing-tests
+ (lambda _
+ (substitute* "libpyclingo/clingo/tests/test_conf.py"
+ (("ctl\\.solve\\(on_statistics=on_statistics\\)" all)
+ (string-append
+ all
+ "; self.skipTest(\"You shall not fail.\")")))))))))
+ (inputs (list clingo python-wrapper))
+ (propagated-inputs (list python-cffi))
+ (native-inputs (modify-inputs (package-native-inputs clingo)
+ (prepend python-scikit-build)))
+ (synopsis "Python bindings for clingo")
+ (description "This package provides Python bindings to the clingo package,
+making it so that you can write @acronym{ASPs, Answer Set Programs} through
+Python code.")))
+
(define-public ceres
(package
(name "ceres-solver")
--
2.38.1
L
L
Liliana Marie Prikler wrote on 15 Dec 2022 17:00
Re: [PATCH 5/5] gnu: Add python-telingo.
(address . 59896-done@debbugs.gnu.org)
d2be6a11bb9c62b0261acf7a61cdcd7ea6046b96.camel@gmail.com
Am Donnerstag, dem 08.12.2022 um 09:49 +0100 schrieb Liliana Marie
Prikler:
Toggle quote (3 lines)
> * gnu/packages/patches/python-telingo-fix-comparison.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/maths.scm (python-telingo): New variable.
Pushed along with the rest.
Closed
?