summary refs log tree commit diff
path: root/gnu/packages/potassco.scm
blob: e6d7caa1ef4fe6f07c9887c78b3195c74aedd818 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022, 2023 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages potassco)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system emacs)
  #:use-module (guix build-system python)
  #:use-module (guix build-system pyproject)
  #:use-module (gnu packages check)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages graphviz)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages sphinx))

(define-public libpotassco
  ;; No public release, update together with clasp
  (let ((revision "1")
        (commit "2f9fb7ca2c202f1b47643aa414054f2f4f9c1821"))
    (package
      (name "libpotassco")
      (version (git-version "0.0" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/potassco/libpotassco")
                      (commit commit)))
                (file-name (git-file-name name version))
                (modules '((guix build utils)))
                (snippet
                 #~(begin
                     (delete-file "tests/catch.hpp")
                     (substitute* (find-files "tests" "\\.cpp")
                       (("\"catch.hpp\"") "<catch/catch.hpp>"))))
                (sha256
                 (base32
                  "1c32f9gqclf7qx07lpx8wd720vfhkjqhzc6nyy8mjmgwpmb3iyyn"))))
      (arguments
       `(#:configure-flags '("-DLIB_POTASSCO_BUILD_TESTS=on"
                             "-DLIB_POTASSCO_INSTALL_LIB=on"
                             "-DBUILD_SHARED_LIBS=on")
         #:phases
         (modify-phases %standard-phases
           (add-after 'unpack 'patch-cmake
             (lambda _
               (substitute* "CMakeLists.txt"
                 ;; clasp expects lowercase potassco and include directory is
                 ;; lowercase as well, so let's use that
                 (("\"cmake/Potassco\"") "\"cmake/potassco\"")
                 (("PotasscoConfig\\.cmake") "potassco-config.cmake")
                 (("PotasscoConfigVersion\\.cmake")
                  "potassco-config-version.cmake"))
               (rename-file "cmake/PotasscoConfig.cmake.in"
                            "cmake/potassco-config.cmake.in"))))))
      (build-system cmake-build-system)
      (native-inputs (list catch2-1))
      (home-page "https://potassco.org/")
      (synopsis "Utility library for Potassco's projects")
      (description "@code{libpotassco} is a utility library providing functions
and datatypes for
@itemize
@item parsing, writing, and converting logic programs in aspif and smodels
format,
@item passing information between a grounder and a solver,
@item and defining and parsing command-line options and for creating
command-line applications.
@end itemize
Furthermore, it comes with the tool @command{lpconvert} that converts either
between aspif and smodels format or to a human-readable text format.")
      (license license:expat))))

(define-public clasp
  (package
    (name "clasp")
    (version "3.3.9")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/potassco/clasp")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "163ps9zq7xppqy9hj5qnw6z5lcjnm4xf5fwjsavpia5ynm3hngcw"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags '("-DCLASP_BUILD_TESTS=on"
                           "-DCLASP_INSTALL_LIB=on"
                           "-DCLASP_USE_LOCAL_LIB_POTASSCO=off"
                           "-DBUILD_SHARED_LIBS=on")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-cmake
           (lambda _
             (substitute* "CMakeLists.txt"
               ;; Use lowercase to be consistent with libpotassco
               (("\"cmake/Clasp\"") "\"cmake/clasp\"")
               (("ClaspConfig\\.cmake") "clasp-config.cmake")
               (("ClaspConfigVersion\\.cmake")
                "clasp-config-version.cmake"))
             (substitute* "cmake/ClaspConfig.cmake.in"
               (("find_package\\(Potassco") "find_package(potassco"))
             (rename-file "cmake/ClaspConfig.cmake.in"
                          "cmake/clasp-config.cmake.in"))))))
    (inputs
     (list libpotassco))
    (home-page "https://potassco.org/")
    (synopsis "Answer set solver")
    (description "clasp is an answer set solver for (extended) normal and
disjunctive logic programs.  The primary algorithm of clasp relies on
conflict-driven nogood learning, a technique that proved very successful for
satisfiability checking (SAT).")
    (license license:expat)))

(define-public clingo
  (package
    (name "clingo")
    (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")
                   (delete-file-recursively "third_party")))
              (sha256
               (base32
                "19s59ndcm2yj0kxlikfxnx2bmp6b7n31wq1zvwc7hyk37rqarwys"))))
    (build-system cmake-build-system)
    (arguments
     (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)")
                (("add_subdirectory\\(third_party\\)")
                 (string-append
                  "find_package(tsl-hopscotch-map)\n"
                  "find_package(tl-optional)\n"
                  "find_package(mpark_variant)\n"
                  "find_package(tsl-sparse-map)\n"
                  "find_package(tsl-ordered-map)\n"
                  "find_package(Catch2 3 REQUIRED)")))
              (substitute* "libclingo/CMakeLists.txt"
                (("\"cmake/Clingo\"") "\"cmake/clingo\"")
                (("ClingoConfig\\.cmake") "clingo-config.cmake")
                (("ClingoConfigVersion\\.cmake")
                 "clingo-config-version.cmake"))
              (substitute* "libgringo/CMakeLists.txt"
                (("mpark::variant") "mpark_variant"))
              (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.3 clasp libpotassco))
    (native-inputs (list mpark-variant
                         pkg-config
                         tl-optional
                         tsl-hopscotch-map
                         tsl-ordered-map
                         tsl-sparse-map))
    (home-page "https://potassco.org/")
    (synopsis "Grounder and solver for logic programs")
    (description "Clingo computes answer sets for a given logic program.")
    (license license:expat)))

(define-public emacs-pasp-mode
  (let ((commit "59385eb0e8ebcfc8c11dd811fb145d4b0fa3cc92")
        (revision "1"))
    (package
     (name "emacs-pasp-mode")
     (version (git-version "0.1.0" revision commit))
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/santifa/pasp-mode")
                    (commit commit)))
              (file-name (git-file-name name version))
              (patches
               (search-patches "emacs-pasp-mode-quote-file-names.patch"))
              (sha256
               (base32
                "1ar4vws3izzmir7m870mccci620ns3c5j26dcmwaxavhgw45wcmf"))))
     (build-system emacs-build-system)
     (arguments
      (list
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'defconst-version
             (lambda _
               (emacs-batch-edit-file "pasp-mode.el"
                 '(progn
                   (search-forward-regexp "(defcustom pasp-mode-version")
                   (forward-sexp)
                   (kill-sexp)
                   (backward-sexp)
                   (beginning-of-line)
                   (kill-sexp)
                   (insert (format "(defconst emacs-pasp-version \"%s\" %s)"
                                   #$version (cadr kill-ring)))
                   (basic-save-buffer)))))
           (add-after 'unpack 'hardcode-clingo
             (lambda* (#:key inputs #:allow-other-keys)
               (emacs-substitute-variables "pasp-mode.el"
                 ("pasp-clingo-path"
                  (search-input-file inputs "/bin/clingo"))))))))
     (inputs (list clingo))
     (home-page "https://github.com/santifa/pasp-mode")
     (synopsis "Major mode for editing answer set programs")
     (description
      "This package provides a major mode for editing answer set programs,
in particular ones that can be solved by @command{clingo}.")
     (license license:gpl3+))))

(define-public python-clingo
  (package
    (inherit clingo)
    (name "python-clingo")
    (version (package-version clingo)) ; for #$version in arguments
    (arguments
     (substitute-keyword-arguments (package-arguments clingo)
       ((#:configure-flags flags #~'())
        #~(cons* "-DCLINGO_BUILD_WITH_PYTHON=pip"
                 "-DCLINGO_USE_LIB=yes"
                 #$flags))
       ((#:imported-modules _ '())
        `(,@%cmake-build-system-modules
          (guix build python-build-system)))
       ((#:modules _ '())
        '((guix build cmake-build-system)
          ((guix build python-build-system) #:prefix python:)
          (guix build utils)))
       ((#: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.\")")))))
            (add-after 'install 'install-distinfo
              (lambda* (#:key inputs outputs #:allow-other-keys)
                (with-directory-excursion (python:site-packages inputs outputs)
                   (let ((dir (string-append "clingo-" #$version ".dist-info")))
                     (mkdir-p dir)
                     (call-with-output-file (string-append dir "/METADATA")
                       (lambda (port)
                         (format port "Metadata-Version: 1.1~%")
                         (format port "Name: clingo~%")
                         (format port "Version: ~a~%" #$version)))))))))))
    (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 python-clorm
  (package
   (name "python-clorm")
   (version "1.4.1")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/potassco/clorm")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32
              "0jx99y71mrgdicn1da5dwz5nzgvvpabrikff783sg4shbv2cf0b5"))))
   (build-system pyproject-build-system)
   (arguments
    (list #:phases
          #~(modify-phases %standard-phases
              (add-before 'check 'fix-breaking-tests
                (lambda _
                  ;; noclingo tests rely on this being set
                  (setenv "CLORM_NOCLINGO" "1")
                  (delete-file "tests/test_mypy_query.py")
                  (substitute* "tests/test_clingo.py"
                    (("self\\.assertTrue\\(os_called\\)" all)
                     (string-append "# " all))))))))
   (propagated-inputs (list python-clingo))
   (native-inputs (list python-typing-extensions))
   (home-page "https://potassco.org")
   (synopsis "Object relational mapping to clingo")
   (description "@acronym{Clorm, Clingo ORM} provides an @acronym{ORM,
Object Relational Mapping} interface to the @acronym{ASP, answer set
programming} solver clingo.  Its goal is to make integration of clingo
into Python programs easier.")
   (license license:expat)))

(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 python-clingraph
  (package
    (name "python-clingraph")
    (version "1.1.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/potassco/clingraph")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0bdhli20nw9qnyxmpisgz7m97d7bwx6lbmxy9bgqvm6mipprnv3n"))))
    (build-system pyproject-build-system)
    (inputs (list dot2tex graphviz))
    (propagated-inputs (list python-clingo
                             python-clorm
                             python-graphviz
                             python-imageio
                             python-jinja2
                             python-jsonschema
                             python-networkx))
    (native-inputs (list dot2tex graphviz python-pylint python-pytest))
    (home-page "https://github.com/potassco/clingraph")
    (synopsis "Visualizer for graphs defined as logic programs")
    (description
     "This package provides a clingo-based visualizer for graphs defined
as logic programs.")
    (license license:expat)))

(define-public python-clinguin
  (package
   (name "python-clinguin")
   (version "1.0.0-beta")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/potassco/clinguin")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32
              "032fnzxv6wl01sdq7n2k0ikajpmkg8ihjh5mck1mwjvmis8z16d4"))
            (modules '((guix build utils)))
            (snippet
             #~(begin
                 (substitute* "setup.cfg"
                   ;; Fun fact of the day
                   ;; some typo squatter hosted
                   ;; a package named tk
                   (("tk") "")
                   (("typing") "typing;python_version<\"3.5\""))))))
   (build-system pyproject-build-system)
   (propagated-inputs
    (list python-clingo
          python-clorm
          python-clingraph
          python-fastapi
          python-httpx
          python-nbconvert
          python-nbformat
          python-nbsphinx
          python-networkx
          python-pillow
          python-pydantic
          `(,python "tk")
          python-sphinx-rtd-theme
          python-traitlets
          python-uvicorn))
   (home-page "https://github.com/potassco/clingraph")
   (synopsis "Clingo-based interactive UI")
   (description "Clinguin is a graphical user interface toolkit for clingo,
which allows user interfaces to be specified entirely as a logic program.")
   (license license:expat)))