aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017-2024 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
;;; Copyright © 2018, 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019, 2021, 2022, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2020 Alexander Krotov <krotov@iitp.ru>
;;; Copyright © 2020 Pierre Langlois <pierre.langlos@gmx.com>
;;; Copyright © 2021, 2023 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2021 Alexandre Hannud Abdo <abdo@member.fsf.org>
;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
;;; 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 graph)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system pyproject)
  #:use-module (guix build-system python)
  #:use-module (guix build-system r)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bioconductor)
  #:use-module (gnu packages bioinformatics)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages c)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cran)
  #:use-module (gnu packages datastructures)
  #:use-module (gnu packages docbook)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages gd)
  #:use-module (gnu packages graphics)
  #:use-module (gnu packages graphviz)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages image)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages machine-learning)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages pretty-print)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-check)
  #:use-module (gnu packages python-compression)
  #:use-module (gnu packages python-science)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages statistics)
  #:use-module (gnu packages swig)
  #:use-module (gnu packages time)
  #:use-module (gnu packages xml))

(define-public plfit
  (package
    (name "plfit")
    (version "0.9.4")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/ntamas/plfit")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "042b60cnsz5wy27sz026xs0mnn9p58j46crgs78skncgkvzqyyc6"))))
    (build-system cmake-build-system)
    (arguments
     '(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON")))
    (home-page "https://github.com/ntamas/plfit")
    (synopsis "Tool for fitting power-law distributions to empirical data")
    (description "The @command{plfit} command fits power-law distributions to
empirical (discrete or continuous) data, according to the method of Clauset,
Shalizi and Newman (@cite{Clauset A, Shalizi CR and Newman MEJ: Power-law
distributions in empirical data.  SIAM Review 51, 661-703 (2009)}).")
    (license license:gpl2+)))

(define-public igraph
  (package
    (name "igraph")
    (version "0.10.7")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/igraph/igraph")
             (commit version)))
       (file-name (git-file-name name version))
       (patches (search-patches "igraph-fix-varargs-integer-size.patch"))
       (modules '((guix build utils)
                  (ice-9 ftw)
                  (srfi srfi-26)))
       (snippet '(begin

                   (delete-file-recursively "vendor")
                   (delete-file-recursively "src/isomorphism/bliss")
                   (substitute* '("src/CMakeLists.txt"
                                  "etc/cmake/benchmark_helpers.cmake")
                     ;; Remove extraneous bundling related variables.
                     ((".*_IS_VENDORED.*") "")
                     ((".*add_sub.*isomorphism/bliss.*") "")
                     (("(.*TARGETS.*)bliss(.*)cxsparse_vendored(.*)pcg(.*)"
                       _ part1 part2 part3 part4)
                      (string-append part1 part2 part3 part4))
                     (("cxsparse_vendored") "cxsparse")
                     ((" pcg ") " pcg_random "))
                   (substitute* "CMakeLists.txt"
                     (("add_sub.*vendor.*") ""))))
       (sha256
        (base32
         "025f9c2jsawniqkig4l5z3v9aw3ipazmnlsf80b653mns5bvj1yn"))))
    (build-system cmake-build-system)
    (arguments
     (list
      #:configure-flags
      #~(list "-DBUILD_SHARED_LIBS=ON"
              ;; Use the same integer width as suitesparse-cxsparse, which
              ;; uses int64_t in SuiteSparse v6.0.0 and later.
              "-DIGRAPH_INTEGER_SIZE=64")
      #:test-target "check"
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'version-file
            (lambda _
              (let ((port (open-file "IGRAPH_VERSION" "w")))
                (display #$version port)
                (close port))))
          (add-after 'unpack 'patch-suitesparse
            (lambda _
              (substitute* '("src/core/sparsemat.c"
                             "include/igraph_sparsemat.h")
                (("<cs/cs\\.h>") "<cs.h>")
                (("cs_igraph") "cs_dl")
                (("__BEGIN_DECLS.*" all)
                 (string-append all "\n#define CS_LONG\n")))))
          (add-after 'unpack 'patch-pcg
            (lambda _
              (substitute* '("src/random/rng_pcg32.c"
                             "src/random/rng_pcg64.c")
                (("#include \"pcg/(.*)\"" _ name)
                 (string-append "#include <" name ">")))))
          (add-after 'unpack 'patch-bliss
            (lambda _
              (substitute* "src/isomorphism/bliss.cc"
                (("#include \"bliss.*")
                 (string-append
                  "#include <bliss/graph.hh>\n"
                  "#include <bliss/digraph.hh>\n")))))
          (add-after 'build 'build-doc
            (lambda _
              (invoke "cmake" "--build" "." "--target" "html")))
          (add-after 'install 'install-doc
            (lambda _
              (copy-recursively
               "doc/html"
               (string-append #$output "/share/doc/"
                              #$name "-" #$version "/html")))))))
    (native-inputs
     (list bison
           docbook-xml-4.3
           docbook-xsl
           flex
           pcg-c
           pkg-config
           ;; For the HTML documentation.
           python
           source-highlight
           xmlto))
    (inputs
     (list arpack-ng
           bliss
           glpk
           ;lapack
           openblas
           plfit
           suitesparse-cxsparse))
    ;; libxml2 is in the 'Requires.private' of igraph.pc.
    (propagated-inputs (list libxml2))
    (home-page "https://igraph.org")
    (synopsis "Network analysis and visualization")
    (description
     "This package provides a library for the analysis of networks and graphs.
It can handle large graphs very well and provides functions for generating
random and regular graphs, graph visualization, centrality methods and much
more.")
    (license license:gpl2+)))

(define-public python-igraph
  ;; Temporarily use a precise commit, as there was a mistake in the last
  ;; release that was fixed by it (see:
  ;; https://github.com/igraph/python-igraph/issues/632).
  (let ((revision "0")
        (commit "b6ebd8eb277fc1d0e33340a6624629a10c638992"))
    (package
      (inherit igraph)
      (name "python-igraph")
      (version (git-version "0.10.4" revision commit))
      (source (origin
                (method git-fetch)
                ;; The PyPI archive lacks tests.
                (uri (git-reference
                      (url "https://github.com/igraph/python-igraph")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "0dhrz5a6pi6vs94fm8q4nmkh6v1nmpw1sk482xls213zcbbh67hd"))))
      (build-system pyproject-build-system)
      (arguments
       (list
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'specify-libigraph-location
              (lambda _
                (let ((igraph #$(this-package-input "igraph")))
                  (substitute* "setup.py"
                    (("(LIBIGRAPH_FALLBACK_INCLUDE_DIRS = ).*" _ var)
                     (string-append
                      var (format #f "[~s]~%"
                                  (string-append igraph "/include/igraph"))))
                    (("(LIBIGRAPH_FALLBACK_LIBRARY_DIRS = ).*" _ var)
                     (string-append
                      var (format #f "[~s]~%"
                                  (string-append igraph "/lib")))))))))))
      (inputs (list igraph))
      (propagated-inputs
       (list python-texttable))
      (native-inputs
       (list python-pytest
             python-setuptools
             python-wheel))
      (home-page "https://igraph.org/python/")
      (synopsis "Python bindings for the igraph network analysis library"))))

(define-public r-rbiofabric
  (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
        (revision "1"))
    (package
      (name "r-rbiofabric")
      (version (string-append "0.3-" revision "." (string-take commit 7)))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/wjrl/RBioFabric")
                      (commit commit)))
                (file-name (string-append name "-" version "-checkout"))
                (sha256
                 (base32
                  "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
      (build-system r-build-system)
      (propagated-inputs
       (list r-igraph))
      (home-page "http://www.biofabric.org/")
      (synopsis "BioFabric network visualization")
      (description "This package provides an implementation of the function
@code{bioFabric} for creating scalable network digrams where nodes are
represented by horizontal lines, and edges are represented by vertical
lines.")
      (license license:expat))))

(define-public python-plotly
  (package
    (name "python-plotly")
    (version "5.20.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/plotly/plotly.py")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0i22sv8p3kl84nkldbv1253kld85rbwp2pdxivxn64wwflfpqvx6"))))
    (build-system python-build-system)
    (arguments
     (list
      #:phases
      #~(modify-phases %standard-phases
          (add-before 'build 'skip-npm
            ;; npm is not packaged so build without it
            (lambda _
              (setenv "SKIP_NPM" "T")))
          (add-after 'unpack 'fix-version
            ;; TODO: Versioneer in Guix gets its release version from the
            ;; parent directory, but the plotly package is located inside a
            ;; depth 3 subdirectory.  Try to use versioneer if possible.
            (lambda _
              (substitute* "packages/python/plotly/setup.py"
                (("version=versioneer.get_version\\(),")
                 (format #f "version=~s," #$version)))
              (substitute* "packages/python/plotly/plotly/version.py"
                (("__version__ = get_versions\\(\\)\\[\"version\"\\]")
                 (format #f "__version__ = ~s" #$version)))))
          (add-after 'fix-version 'chdir
            (lambda _
              (chdir "packages/python/plotly")))
          (replace 'check
            (lambda* (#:key tests? #:allow-other-keys)
              (when tests?
                (invoke "pytest" "-x" "plotly/tests/test_core")
                (invoke "pytest" "-x" "plotly/tests/test_io")
                ;; FIXME: Add optional dependencies and enable their tests.
                ;; (invoke "pytest" "-x" "plotly/tests/test_optional")
                (invoke "pytest" "_plotly_utils/tests")))))))
    (native-inputs
     (list python-ipywidgets python-pytest python-xarray))
    (propagated-inputs
     (list python-ipython
           python-pandas
           python-pillow
           python-requests
           python-retrying
           python-six
           python-tenacity
           python-statsmodels))
    (home-page "https://plotly.com/python/")
    (synopsis "Interactive plotting library for Python")
    (description "Plotly's Python graphing library makes interactive,
publication-quality graphs online.  Examples of how to make line plots, scatter
plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
subplots, multiple-axes, polar charts, and bubble charts.")
    (license license:expat)))

(define-public python-plotly-2.4.1
  (package (inherit python-plotly)
    (version "2.4.1")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "plotly" version))
        (sha256
         (base32
          "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
   (native-inputs '())
   (propagated-inputs
    (list python-decorator
          python-nbformat
          python-pandas
          python-pytz
          python-requests
          python-six))
   (arguments
    (list
     #:tests? #false ;The tests are not distributed in the release
     #:phases
     '(modify-phases %standard-phases
        (add-after 'unpack 'python-compatibility
          (lambda _
            (substitute* "plotly/grid_objs/grid_objs.py"
              (("from collections import MutableSequence")
               "from collections.abc import MutableSequence")))))))))

(define-public python-louvain
  (package
    (name "python-louvain")
    (version "0.16")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "python-louvain" version))
       (patches (search-patches "python-louvain-fix-test.patch"))
       (sha256
        (base32 "0sx53l555rwq0z7if8agirjgw4ddp8r9b949wwz8vlig03sjvfmp"))))
    (build-system python-build-system)
    (native-inputs
     (list python-setuptools-57))       ;for use_2to3 support
    (propagated-inputs
     (list python-networkx python-numpy))
    (home-page "https://github.com/taynaud/python-louvain")
    (synopsis "Louvain algorithm for community detection")
    (description
     "This package provides a pure Python implementation of the Louvain
algorithm for community detection in large networks.")
    (license license:bsd-3)))

(define-public python-vtraag-louvain
  (package
    (name "python-vtraag-louvain")
    (version "0.8.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "louvain" version))
              (sha256
               (base32
                "16l2zi4jwc3vpvpnz32jv7xy0g5087dp9y57wxplj1xa9r312x0i"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:phases
      '(modify-phases %standard-phases
         (add-after 'unpack 'do-not-use-bundled-igraph
           (lambda _
             (substitute* "setup.py"
               (("self.external = False")
                "self.external = True")
               (("self.use_pkgconfig = False")
                "self.use_pkgconfig = True")))))))
    (inputs (list igraph))
    (propagated-inputs (list python-igraph python-setuptools))
    (native-inputs
     (list pkg-config
           python-ddt
           python-setuptools-scm
           python-wheel))
    (home-page "https://github.com/vtraag/louvain")
    (synopsis "Community detection in large networks")
    (description
     "Louvain is a general algorithm for methods of community detection in
large networks.")
    (license license:gpl3+)))

(define-public python-graphtools
  (package
    (name "python-graphtools")
    (version "1.5.3")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/KrishnaswamyLab/graphtools")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1aaxhij4y5z2vvc34qnb5py6nw3ciz35a3z4lfr223f9kvfpqgak"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:phases
      '(modify-phases %standard-phases
         (add-after 'unpack 'patch-tests
           (lambda _
             ;; The warning message has changed in numpy.
             (substitute* "test/test_data.py"
               (("\"A sparse matrix was passed, but.*array.\",")
                "\"Sparse data was passed, but dense data is required. Use '.toarray()' to convert to a dense numpy array.\",")
               ;; anndata prints a warning that causes the test to fail.
               (("import warnings" m)
                (string-append m "\nwarnings.filterwarnings(\"ignore\")")))))
         (replace 'check
           (lambda* (#:key tests? #:allow-other-keys)
             (when tests?
               ;; Incompatibility with sklearn.
               ;; 'kNNLandmarkGraph' object has no attribute '_landmark_op'
               (delete-file "test/test_landmark.py")
               (setenv "LOKY_MAX_CPU_COUNT" "1")
               (invoke "nose2" "-v")))))))
    (propagated-inputs
     (list python-deprecated
           python-future
           python-numpy
           python-pygsp
           python-scikit-learn
           python-scipy
           python-tasklogger))
    (native-inputs
     (list util-linux ;for lscpu
           python-anndata
           python-black
           python-coverage
           python-coveralls
           python-nose
           python-nose2
           python-pandas
           python-parameterized
           python-igraph))
    (home-page "https://github.com/KrishnaswamyLab/graphtools")
    (synopsis "Tools for building and manipulating graphs in Python")
    (description "This package provides tools for building and manipulating
graphs in Python.")
    (license license:gpl3)))

(define-public python-louvain-igraph
  (package
    (name "python-louvain-igraph")
    (version "0.8.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/vtraag/louvain-igraph")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1j2ybihvvzggwjb9zvm829aqb5b94q10h8bw6v0h42xd9w75z9sv"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'find-igraph
            (lambda _
              (setenv "SETUPTOOLS_SCM_PRETEND_VERSION" #$version)
              (substitute* "setup.py"
                (("/usr/include/igraph")
                 (string-append #$(this-package-input "igraph")
                                "/include/igraph"))))))))
    (propagated-inputs (list python-igraph))
    (inputs (list igraph))
    (native-inputs
     (list python-ddt
           python-setuptools
           python-setuptools-scm
           python-wheel
           pkg-config))
    (home-page "https://github.com/vtraag/louvain-igraph")
    (synopsis "Implementation of the Louvain algorithm")
    (description "This package implements the Louvain algorithm for community
detection in C++ and exposes it to Python.  Besides the relative flexibility
of the implementation, it also scales well, and can be run on graphs of
millions of nodes (as long as they can fit in memory).  The core function is
@code{find_partition} which finds the optimal partition using the louvain
algorithm for a number of different methods.")
    (license license:gpl3+)))

(define-public python-pygsp
  (package
    (name "python-pygsp")
    (version "0.5.1")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "PyGSP" version))
       (sha256
        (base32 "002q4z3p3ka81rzhgi66qqmz1ccrg9hwch4bax7jsqixg64asx28"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:test-flags
      ;; These all fail due to a type error in scipy.
      '(list "-k" (string-append "not test_bunny"
                                 " and not test_lowstretchtree"
                                 " and not test_nngraph"
                                 " and not test_plot_graphs"
                                 " and not test_randomregular"))
      #:phases
      '(modify-phases %standard-phases
         (add-after 'unpack 'disable-doctests
           (lambda _
             (substitute* "pygsp/tests/test_all.py"
               (("def test_docstrings.*") "def _disabled_test_docstrings():\n")
               (("return doctest.DocFileSuite.*") "return False\n")
               (("suites.append\\(test_docstrings.*")
                "")))))))
    (propagated-inputs (list python-numpy python-scikit-image python-scipy))
    (native-inputs
     (list python-coverage python-coveralls python-flake8
           python-pytest))
    (home-page "https://github.com/epfl-lts2/pygsp")
    (synopsis "Graph Signal Processing in Python")
    (description "The PyGSP is a Python package to ease signal processing on
graphs.")
    (license license:bsd-3)))

(define-public faiss
  (package
    (name "faiss")
    (version "1.5.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/facebookresearch/faiss")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
              (modules '((guix build utils)))
              (snippet
               '(begin
                  (substitute* "utils.cpp"
                    (("#include <immintrin.h>")
                     "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
                  #t))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags
       (list "-DBUILD_WITH_GPU=OFF"     ; thanks, but no thanks, CUDA.
             "-DBUILD_TUTORIAL=OFF")    ; we don't need those
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'prepare-build
           (lambda _
             (let ((features (list ,@(let ((system (or (%current-target-system)
                                                       (%current-system))))
                                       (cond
                                        ((string-prefix? "x86_64" system)
                                         '("-mavx" "-msse2" "-mpopcnt"))
                                        ((string-prefix? "i686" system)
                                         '("-msse2" "-mpopcnt"))
                                        (else
                                         '()))))))
               (substitute* "CMakeLists.txt"
                 (("-m64") "")
                 (("-mpopcnt") "")      ; only some architectures
                 (("-msse4")
                  (string-append
                   (string-join features)
                   " -I" (getcwd)))
                 ;; Build also the shared library
                 (("ARCHIVE DESTINATION lib")
                  "LIBRARY DESTINATION lib")
                 (("add_library.*" m)
                  "\
add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
\n")))

             ;; See https://github.com/facebookresearch/faiss/issues/520
             (substitute* "IndexScalarQuantizer.cpp"
               (("#define USE_AVX") ""))

             ;; Make header files available for compiling tests.
             (mkdir-p "faiss")
             (for-each (lambda (file)
                         (mkdir-p (string-append "faiss/" (dirname file)))
                         (copy-file file (string-append "faiss/" file)))
                       (find-files "." "\\.h$"))
             #t))
         (replace 'check
           (lambda _
             (invoke "make" "-C" "tests"
                     (format #f "-j~a" (parallel-job-count)))))
         (add-after 'install 'remove-tests
           (lambda* (#:key outputs #:allow-other-keys)
             (delete-file-recursively
              (string-append (assoc-ref outputs "out")
                             "/test"))
             #t)))))
    (inputs
     (list openblas))
    (native-inputs
     (list googletest))
    (home-page "https://github.com/facebookresearch/faiss")
    (synopsis "Efficient similarity search and clustering of dense vectors")
    (description "Faiss is a library for efficient similarity search and
clustering of dense vectors.  It contains algorithms that search in sets of
vectors of any size, up to ones that possibly do not fit in RAM.  It also
contains supporting code for evaluation and parameter tuning.")
    (license license:bsd-3)))

(define-public python-faiss
  (package (inherit faiss)
    (name "python-faiss")
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'chdir
           (lambda _ (chdir "python") #t))
         (add-after 'chdir 'build-swig
           (lambda* (#:key inputs #:allow-other-keys)
             (with-output-to-file "../makefile.inc"
               (lambda ()
                 (let ((python-version ,(version-major+minor (package-version python))))
                   (format #t "\
PYTHONCFLAGS =-I~a/include/python~a/ -I~a/lib/python~a/site-packages/numpy/core/include
LIBS = -lpython~a -lfaiss
SHAREDFLAGS = -shared -fopenmp
CXXFLAGS = -fpermissive -fopenmp -fPIC
CPUFLAGS = ~{~a ~}~%"
                           (assoc-ref inputs "python*") python-version
                           (assoc-ref inputs "python-numpy") python-version
                           python-version
                           (list ,@(let ((system (or (%current-target-system)
                                                     (%current-system))))
                                     (cond
                                       ((string-prefix? "x86_64" system)
                                        '("-mavx" "-msse2" "-mpopcnt"))
                                       ((string-prefix? "i686" system)
                                        '("-msse2" "-mpopcnt"))
                                       (else
                                         '()))))))))
             (substitute* "Makefile"
               (("../libfaiss.a") ""))
             (invoke "make" "cpu"))))))
    (inputs
     `(("faiss" ,faiss)
       ("openblas" ,openblas)
       ("python*" ,python)
       ("swig" ,swig)))
    (propagated-inputs
     (list python-matplotlib python-numpy))
    (description "Faiss is a library for efficient similarity search and
clustering of dense vectors.  This package provides Python bindings to the
Faiss library.")))

(define-public python-leidenalg
  (package
    (name "python-leidenalg")
    (version "0.9.1")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "leidenalg" version))
       (sha256
        (base32
         "1wvmi6ca9kf8pbxg6b18n64h82wr9a6wcdazyn82pww0dwxzwp3y"))))
    (build-system python-build-system)
    (arguments
     '(#:tests? #f                      ;tests are not included
       #:phases (modify-phases %standard-phases
                  (add-after 'unpack 'fix-requirements
                    (lambda _
                      (substitute* "setup.py"
                        (("self.external = False")
                         "self.external = True")
                        (("self.use_pkgconfig = False")
                         "self.use_pkgconfig = True")
                        (("python-igraph >=")
                         "igraph >=")))))))
    (native-inputs
     (list pkg-config python-setuptools-scm))
    (inputs
     (list igraph))
    (propagated-inputs
     (list python-igraph))
    (home-page "https://github.com/vtraag/leidenalg")
    (synopsis "Community detection in large networks")
    (description
     "Leiden is a general algorithm for methods of community detection in
large networks.  This package implements the Leiden algorithm in C++ and
exposes it to Python.  Besides the relative flexibility of the implementation,
it also scales well, and can be run on graphs of millions of nodes (as long as
they can fit in memory).  The core function is @code{find_partition} which
finds the optimal partition using the Leiden algorithm, which is an extension
of the Louvain algorithm, for a number of different methods.")
    (license license:gpl3+)))

(define-public edge-addition-planarity-suite
  (package
    (name "edge-addition-planarity-suite")
    (version "3.0.2.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url (string-append "https://github.com/graph-algorithms/"
                                  name))
              (commit (string-append "Version_" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1c7bnxgiz28mqsq3a3msznmjq629w0qqjynm2rqnnjn2qpc22h3i"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake libtool))
    (synopsis "Embedding of planar graphs")
    (description "The package provides a reference implementation of the
linear time edge addition algorithm for embedding planar graphs and
isolating planarity obstructions.")
    (license license:bsd-3)
    (home-page
      "https://github.com/graph-algorithms/edge-addition-planarity-suite")))

(define-public rw
  (package
    (name "rw")
    ;; There is a version 0.8, but the tarball is broken with symlinks
    ;; to /usr/share.
    (version "0.9")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://sourceforge/rankwidth/"
                                  "rw-" version ".tar.gz"))
              (sha256
               (base32
                "0hdlxxmlccb6fp7g58zv0rdzpbyjn9bgqlf052sgrk95zq33bq61"))
              (patches (search-patches "rw-igraph-0.10.patch"))))
    (build-system gnu-build-system)
    (native-inputs (list pkg-config))
    (inputs (list igraph))
    (home-page "https://sourceforge.net/projects/rankwidth/")
    (synopsis "Rank-width and rank-decomposition of graphs")
    (description "rw computes rank-width and rank-decompositions
of graphs.")
    (license license:gpl2+)))

(define-public mscgen
  (package
    (name "mscgen")
    (version "0.20")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
                           version ".tar.gz"))
       (sha256
        (base32
         "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
    (build-system gnu-build-system)
    (native-inputs
     (list pkg-config))
    (inputs
     (list fontconfig freetype gd libjpeg-turbo libpng zlib))
    (home-page "https://www.mcternan.me.uk/mscgen/")
    (synopsis "Message Sequence Chart Generator")
    (description "Mscgen is a small program that parses Message Sequence Chart
descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
the output.  Message Sequence Charts (MSCs) are a way of representing entities
and interactions over some time period and are often used in combination with
SDL.  MSCs are popular in Telecoms to specify how protocols operate although
MSCs need not be complicated to create or use.  Mscgen aims to provide a simple
text language that is clear to create, edit and understand, which can also be
transformed into common image formats for display or printing.")
    (license license:gpl2+)))

(define-public python-graph-tool
  (package
    (name "python-graph-tool")
    (version "2.59")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://downloads.skewed.de/graph-tool/graph-tool-"
                    version ".tar.bz2"))
              (sha256
               (base32
                "1bmck5fcihj9lr5kd8x624bdi9xhfc13pl4mwzv74jr5lz07kr6d"))))
    (build-system gnu-build-system)
    (arguments
     `(#:imported-modules (,@%default-gnu-imported-modules
                           (guix build python-build-system))
       #:modules (,@%default-gnu-modules
                  ((guix build python-build-system) #:select (site-packages)))
       ;; The build process peaks around 4GB/RAM per core.
       #:parallel-build? #f
       #:configure-flags
       (list (string-append "--with-boost="
                            (assoc-ref %build-inputs "boost"))
             (string-append "--with-python-module-path="
                            (site-packages %build-inputs %outputs)))))
    (native-inputs
     (list ncurses pkg-config))
    (inputs
     (list boost
           cairomm-1.14
           cgal
           expat
           gmp
           gtk+
           python-wrapper
           sparsehash))
    (propagated-inputs
     (list python-matplotlib
           python-numpy
           python-pycairo
           python-scipy
           python-zstandard))
    (synopsis "Manipulate and analyze graphs with Python efficiently")
    (description "Graph-tool is an efficient Python module for manipulation
and statistical analysis of graphs (a.k.a. networks).  Contrary to most other
Python modules with similar functionality, the core data structures and
algorithms are implemented in C++, making extensive use of template
metaprogramming, based heavily on the Boost Graph Library.  This confers it a
level of performance that is comparable (both in memory usage and computation
time) to that of a pure C/C++ library.")
    (home-page "https://graph-tool.skewed.de/")
    (license license:lgpl3+)))
th-workaround ;; Calls to the realpath function can set errno even if the return ;; value of the function indicates that there is no error, which ;; make massert consider that there was an error. (lambda _ (substitute* "gcl/o/main.c" (("massert\\(realpath\\(s,o\\)\\);" all) "massert((realpath(s, o) != NULL) && ((errno = 0) == 0));")))) (add-after 'unpack 'fix-missing-enum (lambda _ ;; The 'disassembler_style' enum is not defined anywhere, ;; and the parameter is not used... (substitute* "gcl/o/main.c" (("my_fprintf_styled\\(void \\*v,enum disassembler_style,") "my_fprintf_styled(void *v,int disassembler_style,")))) (add-after 'unpack 'fix-makefile ;; The "final" target doesn't exist. (lambda _ (substitute* "gcl/makefile" (("\\$\\(MAKE\\) -C \\$\\(PORTDIR\\) final") "$(MAKE) -C $(PORTDIR)")))) (add-before 'configure 'pre-conf (lambda* (#:key inputs #:allow-other-keys) (chdir "gcl") (substitute* (append '("pcl/impl/kcl/makefile.akcl" "add-defs" "unixport/makefile.dos" "add-defs.bat" "gcl-tk/makefile.prev" "add-defs1") (find-files "h" "\\.defs")) (("SHELL=/bin/bash") (string-append "SHELL=" (which "bash"))) (("SHELL=/bin/sh") (string-append "SHELL=" (which "sh")))) (substitute* "h/linux.defs" (("#CC") "CC") (("-fwritable-strings") "") (("-Werror") "")) (substitute* "lsp/gcl_top.lsp" (("\"cc\"") (string-append "\"" (assoc-ref %build-inputs "gcc") "/bin/gcc\"")) (("\\(or \\(get-path \\*cc\\*\\) \\*cc\\*\\)") "*cc*") (("\"ld\"") (string-append "\"" (assoc-ref %build-inputs "binutils") "/bin/ld\"")) (("\\(or \\(get-path \\*ld\\*\\) \\*ld\\*\\)") "*ld*") (("\\(get-path \"objdump --source \"\\)") (string-append "\"" (assoc-ref %build-inputs "binutils") "/bin/objdump --source \""))))) (add-after 'install 'wrap (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((gcl #$output) (input-path (lambda (lib path) (string-append (assoc-ref inputs lib) path))) (binaries '("binutils"))) ;; GCC and the GNU binutils are necessary for GCL to be ;; able to compile Lisp functions and programs (this is ;; a standard feature in Common Lisp). While the ;; the location of GCC is specified in the make-flags, ;; the GNU binutils must be available in GCL's $PATH. (wrap-program (string-append gcl "/bin/gcl") `("PATH" prefix ,(map (lambda (binary) (input-path binary "/bin")) binaries)))))) ;; drop strip phase to make maxima build, see ;; https://www.ma.utexas.edu/pipermail/maxima/2008/009769.html (delete 'strip)))) (inputs (list bash-minimal gmp libtirpc readline)) (native-inputs (list m4 texinfo)) (home-page "https://www.gnu.org/software/gcl/") (synopsis "Common Lisp implementation") (description "GCL is an implementation of the Common Lisp language. It features the ability to compile to native object code and to load native object code modules directly into its lisp core. It also features a stratified garbage collection strategy, a source-level debugger and a built-in interface to the Tk widget system.") (license license:lgpl2.0+))) (define-public janet (package (name "janet") (version "1.36.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/janet-lang/janet") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1jy4ib6jjxngn6vcy45y5dl24q0lrgl4j6rsx8y4gaih2i4sq1ll")))) (build-system gnu-build-system) (arguments (list #:make-flags #~(list (string-append "DESTDIR=" #$output) (string-append "PREFIX=") (string-append "CC=" #$(cc-for-target))) #:test-target "test" #:phases #~(modify-phases %standard-phases (delete 'configure)))) (home-page "https://janet-lang.org/") (synopsis "Functional, imperative and embeddable programming language") (description "Janet is a functional and imperative programming language. It can be used for rapid prototyping, dynamic systems, and other domains where dynamic languages shine. You can also add Janet scripting to an application by embedding a single C file and two headers. It can be easily ported to new platforms. The entire language (core library, interpreter, compiler, assembler, PEG) is less than 1MB.") (license license:expat))) (define-public lisp-repl-core-dumper (package (name "lisp-repl-core-dumper") (version "0.8.0") (source (origin (method git-fetch) (uri (git-reference (url "https://gitlab.com/ambrevar/lisp-repl-core-dumper.git") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "04c12gi5izpkv8ha98z9qdkbmyrsq6ga060adrx53da8z31gnhk1")))) (build-system copy-build-system) (arguments '(#:install-plan '(("lisp-repl-core-dumper" "bin/")) #:phases (modify-phases %standard-phases (add-before 'install 'fix-utils-path (lambda* (#:key inputs #:allow-other-keys) (let* ((cat (search-input-file inputs "/bin/cat")) (paste (search-input-file inputs "/bin/paste")) (sort (search-input-file inputs "/bin/sort")) (basename (search-input-file inputs "/bin/basename")) (sed (search-input-file inputs "/bin/sed"))) (substitute* "lisp-repl-core-dumper" (("\\$\\(basename") (string-append "$(" basename)) (("\\<cat\\>") cat) (("\\<paste\\>") paste) (("\\<sed\\>") sed) (("\\<sort\\>") sort)))))))) (inputs `(("coreutils" ,coreutils-minimal) ("sed" ,sed))) (home-page "https://gitlab.com/ambrevar/lisp-repl-core-dumper") (synopsis "Generate REPL-optimized Lisp cores on demand") (description "This tool generates Lisp images that can embed the provided systems and make for REPLs that start blazing fast. @itemize @item It’s portable and should work with any compiler. @item It works for any REPL. @item It allows you to include arbitrary libraries. @end itemize\n") (license license:gpl3+))) (define-public lush2 (package (name "lush2") (version "2.0.1") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/lush/lush2/lush-" version ".tar.gz")) (modules '((guix build utils))) (snippet '(begin (substitute* "src/unix.c" (("\\{ \"LUSH_DATE\", __DATE__ \\},") "") (("\\{ \"LUSH_TIME\", __TIME__ \\},") "")) (substitute* "src/main.c" (("\" \\(built \" __DATE__ \"\\)\"") "")) #t)) (sha256 (base32 "02pkfn3nqdkm9fm44911dbcz0v3r0l53vygj8xigl6id5g3iwi4k")))) (build-system gnu-build-system) (arguments `(;; We have to add these LIBS so that they are found. #:configure-flags (list "LIBS=-lz" "X_EXTRA_LIBS=-lfontconfig" "--with-x") #:tests? #f)) ; No make check. (native-inputs (list intltool)) (inputs `(("alsa-lib" ,alsa-lib) ("sdl" ,sdl) ("sdl-image" ,sdl-image) ("sdl-mixer" ,sdl-mixer) ("sdl-net" ,sdl-net) ("sdl-ttf" ,sdl-ttf) ("libxft" ,libxft) ("fontconfig" ,fontconfig) ("gsl" ,gsl) ("openblas" ,openblas) ("glu" ,glu) ("mesa" ,mesa) ("mesa-utils" ,mesa-utils) ("binutils" ,binutils) ("libiberty" ,libiberty) ("readline" ,readline) ("zlib" ,zlib) ("gettext-minimal" ,gettext-minimal))) (synopsis "Lisp Universal Shell") (description "Lush is an object-oriented Lisp interpreter/compiler with features designed to please people who want to prototype large numerical applications. Lush includes an extensive library of vector/matrix/tensor manipulation, numerous numerical libraries (including GSL, LAPACK, and BLAS), a set of graphic functions, a simple GUI toolkit, and interfaces to various graphic and multimedia libraries such as OpenGL, SDL, Video4Linux, and ALSA (video/audio grabbing), and others. Lush is an ideal frontend script language for programming projects written in C or other languages. Lush also has libraries for Machine Learning, Neural Nets and statistical estimation.") (home-page "https://lush.sourceforge.net/") (license license:lgpl2.1+))) (define-public picolisp (package (name "picolisp") (version "24.9") (supported-systems '("aarch64-linux" "powerpc64le-linux" "x86_64-linux")) (source (origin (method url-fetch) (uri (string-append "https://software-lab.de/picoLisp-" version ".tgz")) (sha256 (base32 "1bsp14vjzvlav813mxzgigcdrmsxhrrhlhdzfdvdq6havacm0cwf")))) (build-system gnu-build-system) (inputs (list clang readline libffi openssl pkg-config)) (arguments '(#:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'fix-paths (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (picolisp-shebang (string-append "#!" out "/bin/picolisp " out "/lib/picolisp/lib.l")) (pil-shebang (string-append "#!" out "/bin/pil"))) (substitute* '("bin/pil" "bin/psh" "bin/pty" "bin/vip" "bin/watchdog") (("#\\!bin/picolisp lib.l") picolisp-shebang) (("#\\!\\.\\./bin/picolisp \\.\\./lib.l") picolisp-shebang) (("#\\!/usr/bin/picolisp /usr/lib/picolisp/lib.l") picolisp-shebang) (("#\\!/usr/bin/pil") pil-shebang))))) (replace 'build (lambda _ (invoke "make" "-C" "src"))) (add-before 'check 'set-home-for-tests (lambda _ (setenv "HOME" "/tmp"))) (replace 'check (lambda _ (invoke "./pil" "test/lib.l" "-bye" "+"))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (doc (string-append out "/share/doc")) (man (string-append out "/share/man")) (picolisp (string-append out "/lib/picolisp"))) (copy-recursively "man" man) (copy-recursively "doc" doc) (copy-recursively "." picolisp) (for-each (lambda (name) (let ((path (string-append picolisp "/" name))) (delete-file-recursively path))) '("doc" "COPYING" "INSTALL" "man" "pil" "README" "src" "test")) (mkdir-p bin) (for-each (lambda (name) (symlink name (string-append bin "/" (basename name)))) (find-files (string-append picolisp "/bin"))))))))) (synopsis "Interpreter for the PicoLisp programming language") (description "PicoLisp is a programming language, or really a programming system, including a built-in database engine and a GUI system.") (home-page "https://picolisp.com/wiki/?home") (license license:expat))) (define-public roswell (package (name "roswell") (version "23.10.14.114") (home-page "https://github.com/roswell/roswell") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/roswell/roswell") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "05w5sjh1bfy2wnblc09cb9qs8h7hxkx5hcqlbgpn7md32b0m4h7g")))) (build-system gnu-build-system) (arguments (list #:configure-flags #~(list (string-append "--prefix=" #$output)) #:tests? #f)) (native-inputs (list autoconf automake intltool)) (inputs (list curl)) (propagated-inputs ;; Has to be propagated in order to be found during setup. (list gnu-make patchelf)) (synopsis "Common Lisp implementation manager, launcher, and more") (description "Roswell started out as a command-line tool with the aim to make installing and managing Common Lisp implementations really simple and easy. Roswell has now evolved into a full-stack environment for Common Lisp development, and has many features that makes it easy to test, share, and distribute your Lisp applications. Roswell is still in beta. Despite this, the basic interfaces are stable and not likely to change.") (license license:expat))) (define-public s7-bootstrap ;; Need s7-bootstrap to build libc_s7.so (for the REPL) and run tests (let ((commit "23a64facfac06c4bc23a7de8f04691c55f88bd40") ;no releases (revision "0")) (hidden-package (package (name "s7-bootstrap") (version (git-version "24.1" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://cm-gitlab.stanford.edu/bil/s7.git") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0fiw8lb7rswglixvn271la2q2hgwszrf2ckykhr6jjxdvmb9a7d0")) (patches (search-patches "s7-flint-3.patch")))) (build-system gnu-build-system) (arguments (list #:tests? #f ;no tests in bootstrap #:phases #~(modify-phases %standard-phases (delete 'configure) ;no configure (replace 'build (lambda _ ;; using build commands from s7 home page (display "[BUILD] repl\n") (invoke #$(cc-for-target) "s7.c" "-o" "repl" "-I." "-O2" "-g" "-DWITH_MAIN" (string-append "-DS7_LOAD_PATH=\"" #$output "/share/s7/scm\"") "-ldl" "-lm" "-Wl,-export-dynamic") (display "[BUILD] nrepl\n") (invoke #$(cc-for-target) "s7.c" "-o" "nrepl" "-I." "-O2" "-g" "-DWITH_MAIN" "-DWITH_NOTCURSES" (string-append "-DS7_LOAD_PATH=\"" #$output "/share/s7/scm\"") "-ldl" "-lm" "-lnotcurses-core" "-Wl,-export-dynamic") (display "[BUILD] libarb_s7.so\n") (invoke #$(cc-for-target) "libarb_s7.c" "-I." "-O2" "-g" "-shared" "-o" "libarb_s7.so" "-lflint" "-lmpc" "-fPIC") (display "[BUILD] libnotcurses_s7.so\n") (invoke #$(cc-for-target) "notcurses_s7.c" "-I." "-O2" "-g" "-shared" "-o" "libnotcurses_s7.so" "-lnotcurses-core" "-fPIC") ;; Need s7.o and ffitest for tests (display "[BUILD] s7.o\n") (invoke #$(cc-for-target) "-c" "s7.c" "-o" "s7.o" "-I." "-O2" "-ldl" "-lm") (display "[BUILD] ffitest\n") (invoke #$(cc-for-target) "-o" "ffitest" "ffitest.c" "-g2" "s7.o" "-lm" "-I." "-ldl" "-Wl,-export-dynamic"))) (add-before 'check 'install-scm ;; scm files need to be installed before testing (lambda _ (for-each (lambda (x) (install-file x (string-append #$output "/share/s7/scm/"))) (find-files "." "\\.scm")))) (replace 'install (lambda _ (let ((bin (string-append #$output "/bin")) (share (string-append #$output "/share/s7/")) (doc (string-append #$output "/share/doc/s7/")) (lib (string-append #$output "/lib")) (inc (string-append #$output "/include/"))) (install-file "repl" bin) (install-file "nrepl" bin) (install-file "ffitest" bin) (install-file "libarb_s7.so" lib) (install-file "libnotcurses_s7.so" lib) (install-file "s7.c" share) (install-file "s7.h" inc) (install-file "s7.html" doc))))))) (inputs (list flint mpc notcurses)) (home-page "https://ccrma.stanford.edu/software/snd/snd/s7.html") (synopsis "Scheme interpreter intended as an extension language") (description "s7 is a Scheme interpreter intended as an extension language for other applications. It exists as just two files, @code{s7.c} and @code{s7.h}, that may be copied into the source tree of another application. There are no libraries, no run-time init files, and no configuration scripts. It can also be built as a stand-alone REPL interpreter.") (license license:bsd-0))))) (define-public s7 (package (inherit s7-bootstrap) (name "s7") (arguments (substitute-keyword-arguments (strip-keyword-arguments '(#:tests?) (package-arguments s7-bootstrap)) ((#:phases phases) #~(modify-phases #$phases (add-after 'unpack 'patch (lambda _ (substitute* "s7.c" (("libc_s7.so") (string-append #$output "/lib/libc_s7.so"))))) (add-after 'build 'build-full (lambda _ (invoke "repl" "./libc.scm"))) (replace 'check (lambda* (#:key tests? #:allow-other-keys) (when tests? (invoke "repl" "./s7test.scm")))) (add-after 'install 'install-full (lambda _ (install-file "libc_s7.so" (string-append #$output "/lib/")) (delete-file (string-append #$output "/bin/ffitest")))))))) (native-inputs (list s7-bootstrap)) (properties (alist-delete 'hidden? (package-properties s7-bootstrap))))) (define-public sbcl (package (name "sbcl") (version "2.4.10") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-" version "-source.tar.bz2")) (sha256 (base32 "1y72ql8dxwjkwkikyk26w4n38p6apvv2l7440kp3x4fjd5mkksyf")) (modules '((guix build utils))) (snippet '(begin ;; Don't force ARMv5. (substitute* "src/runtime/Config.arm-linux" (("-march=armv5t") "")))))) (build-system gnu-build-system) (outputs '("out" "doc")) (native-inputs ;; From INSTALL: ;; Supported build hosts are: ;; SBCL ;; CMUCL ;; CCL (formerly known as OpenMCL) ;; ABCL (recent versions only) ;; CLISP (only some versions: 2.44.1 is OK, 2.47 is not) ;; XCL ;; ;; From NEWS: ;; * build enhancement: new host quirks mechanism, support for building under ;; ABCL and ECL (as well as CCL, CMUCL, CLISP and SBCL itself) ;; ;; CCL is not bootstrappable so it won't do. CLISP 2.49 seems to work. ;; ECL too. As of 2020-07-01, ECL was last updated in 2020 while CLISP ;; was last updated in 2010, and both take about the same time to build SBCL. ;; ;; For now we stick to CLISP as the default for all systems. In any event, keep ;; the `match' here to make it easier to change the host compiler for various ;; architectures. Consider switching to ECL if it gets faster than CLISP ;; (maybe post 2020 release). (list (match (%current-system) ("powerpc-linux" ; CLISP fails to build, needs investigating. ecl) (_ clisp)) cl-asdf ed inetutils ;for hostname(1) texinfo (texlive-updmap.cfg (list texlive-texinfo)) which)) (inputs (list bash-minimal gmp ; for sb-gmp mpfr ; for sb-mpfr (list zstd "lib"))) (arguments `(#:modules ((guix build gnu-build-system) (guix build utils) (srfi srfi-1)) #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'fix-build-id ;; One of the build scripts makes a build id using the current date. ;; Replace it with a reproducible id using a part of the output hash. (lambda* (#:key outputs #:allow-other-keys) (let ((hash (substring (assoc-ref outputs "out") (+ (string-length (%store-directory)) 1) (+ (string-length (%store-directory)) 9)))) (substitute* "make-config.sh" (("echo .* > output/build-id.inc") (string-append "echo '\"'guix-sbcl-" hash "'\"' > output/build-id.inc")))))) (add-after 'unpack 'replace-asdf ;; SBCL developers have not committed to keeping ASDF up to date ;; due to breaking changes [1]. Guix can handle this situation ;; easily, and it behooves us to have more control over what version ;; of ASDF we use to build software; therefore, replace the contrib ;; ASDF with the version packaged into Guix. ;; [1] - https://bugs.launchpad.net/sbcl/+bug/1823442 (lambda* (#:key inputs #:allow-other-keys) (let* ((cl-asdf (assoc-ref inputs "cl-asdf")) (guix-asdf (string-append cl-asdf "/share/common-lisp/source/asdf/asdf.lisp")) (contrib-asdf "contrib/asdf/asdf.lisp")) (copy-file guix-asdf contrib-asdf)))) (add-before 'build 'patch-unix-tool-paths (lambda* (#:key outputs inputs #:allow-other-keys) (let ((out (assoc-ref outputs "out")) (bash (assoc-ref inputs "bash")) (coreutils (assoc-ref inputs "coreutils")) (ed (assoc-ref inputs "ed"))) (define (quoted-path input path) (string-append "\"" input path "\"")) ;; Patch absolute paths in string literals. Note that this ;; occurs in some .sh files too (which contain Lisp code). Use ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded. (with-fluids ((%default-port-encoding #f)) ;; The removed file is utf-16-be encoded, which gives substitute* ;; trouble. It does not contain references to the listed programs. (substitute* (delete "./tests/data/compile-file-pos-utf16be.lisp" (find-files "." "\\.(lisp|sh)$")) (("\"/bin/sh\"") (quoted-path bash "/bin/sh")) (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env")) (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat")) (("\"/bin/ed\"") (quoted-path ed "/bin/ed")) (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo")) (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname")))) ;; This one script has a non-string occurrence of /bin/sh. (substitute* '("tests/foreign.test.sh") ;; Leave whitespace so we don't match the shebang. ((" /bin/sh ") " sh ")) ;; This file contains a module that can create executable files ;; which depend on the presence of SBCL. It generates shell ;; scripts doing "exec sbcl ..." to achieve this. We patch both ;; the shebang and the reference to "sbcl", tying the generated ;; executables to the exact SBCL package that generated them. (substitute* '("contrib/sb-executable/sb-executable.lisp") (("/bin/sh") (string-append bash "/bin/sh")) (("exec sbcl") (string-append "exec " out "/bin/sbcl"))) ;; Disable some tests that fail in our build environment. (substitute* '("contrib/sb-bsd-sockets/tests.lisp") ;; This requires /etc/protocols. (("\\(deftest get-protocol-by-name/error" all) (string-append "#+nil ;disabled by Guix\n" all))) (substitute* '("contrib/sb-posix/posix-tests.lisp") ;; These assume some users/groups which we don't have. (("\\(deftest pwent\\.[12]" all) (string-append "#+nil ;disabled by Guix\n" all)) (("\\(deftest grent\\.[12]" all) (string-append "#+nil ;disabled by Guix\n" all)))))) (add-before 'build 'fix-contrib-library-path (lambda* (#:key inputs #:allow-other-keys) (let ((gmp (assoc-ref inputs "gmp")) (mpfr (assoc-ref inputs "mpfr"))) (substitute* '("contrib/sb-gmp/gmp.lisp") (("\"libgmp\\.so") (string-append "\"" gmp "/lib/libgmp.so"))) (substitute* '("contrib/sb-mpfr/mpfr.lisp") (("\"libmpfr\\.so") (string-append "\"" mpfr "/lib/libmpfr.so")))))) (replace 'build (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" "gcc") (invoke "sh" "make.sh" ,@(match (%current-system) ("powerpc-linux" `("ecl")) (_ `("clisp"))) (string-append "--prefix=" (assoc-ref outputs "out")) ,@(if (or (target-ppc32?) (target-x86-32?)) ;; 3072 is too much for these architectures. `("--dynamic-space-size=2048") `("--dynamic-space-size=3072")) "--with-sb-core-compression" "--with-sb-xref-for-internals" ;; SB-SIMD will only be built on x86_64 CPUs supporting ;; AVX2 instructions. Some x86_64 CPUs don't, so for reproducibility ;; we disable it. "--without-sb-simd"))) (add-after 'build 'build-shared-library (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" "gcc") (invoke "sh" "make-shared-library.sh"))) (replace 'install (lambda _ (invoke "sh" "install.sh"))) (add-after 'build 'build-doc (lambda _ (with-directory-excursion "doc/manual" (and (invoke "make" "info") (invoke "make" "dist"))))) (add-after 'build 'build-source (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (rc (string-append out "/lib/sbcl/sbclrc")) (source-dir (string-append out "/share/sbcl"))) (for-each (lambda (p) (copy-recursively p (string-append source-dir "/" p))) '("src" "contrib")) (mkdir-p (dirname rc)) (with-output-to-file rc (lambda () (display (string-append "(sb-ext:set-sbcl-source-location \"" source-dir "\")") )))))) (add-after 'install 'remove-coreutils-references ;; They are only useful on non-Linux, non-SBCL. (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (share-dir (string-append out "/share/sbcl/"))) (substitute* (string-append share-dir "src/code/run-program.lisp") (("\\(run-program \".*uname\"") "(run-program \"uname\"")) (substitute* (string-append share-dir "contrib/asdf/asdf.lisp") (("\\(\".*/usr/bin/env\"") "(\"/usr/bin/env\"")) (substitute* (string-append share-dir "contrib/asdf/uiop.lisp") (("\\(\".*/usr/bin/env\"") "(\"/usr/bin/env\""))))) (add-after 'install 'install-shared-library (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (lib-dir (string-append out "/lib"))) (install-file "src/runtime/libsbcl.so" lib-dir)))) (add-after 'install 'install-doc (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (doc (assoc-ref outputs "doc")) (old-doc-dir (string-append out "/share/doc")) (new-doc/sbcl-dir (string-append doc "/share/doc/sbcl"))) (rmdir (string-append old-doc-dir "/sbcl/html")) (mkdir-p new-doc/sbcl-dir) (copy-recursively (string-append old-doc-dir "/sbcl") new-doc/sbcl-dir) (delete-file-recursively old-doc-dir))))) ;; No 'check' target, though "make.sh" (build phase) runs tests. #:tests? #f)) (native-search-paths (list (search-path-specification (variable "XDG_DATA_DIRS") (files '("share"))) (search-path-specification (variable "XDG_CONFIG_DIRS") (files '("etc"))))) (home-page "https://www.sbcl.org/") (supported-systems (remove target-hurd? %supported-systems)) (synopsis "Common Lisp implementation") (description "Steel Bank Common Lisp (SBCL) is a high performance Common Lisp compiler. In addition to the compiler and runtime system for ANSI Common Lisp, it provides an interactive environment including a debugger, a statistical profiler, a code coverage tool, and many other extensions.") ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT ;; loop macro has its own license. See COPYING file for further notes. (license (list license:public-domain license:bsd-2 (license:x11-style "file://src/code/loop.lisp"))))) (define man-for-txr (let ((commit "dfbf19b9a96474b8c1bacac85e43605e5691ceb2") ;; Number of additional commits since the last tag (see the output of ;; "git describe --tags"). (revision "41")) (package (name "man-for-txr") (version (git-version "1.6g" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "http://www.kylheku.com/git/man/") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1zy0g8fj9nsfwzvg88hyaiy94r8j14xhs8vy2ln2niqdm6x2lvy2")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; There are no tests. #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-man2html-makefile (lambda _ (substitute* "man2html/Makefile.in" ;; It inadvertently ignores @bindir@. (("^(bindir = \\$\\(DESTDIR\\)\\$\\(PREFIX\\)).*" _ prefix) (string-append prefix "@bindir@\n"))) #t)) (add-after 'unpack 'delete-generated-files (lambda _ (for-each delete-file (append (list "conf_script") (map (lambda (d) (string-append d "/Makefile")) '("." "man" "man2html" "src")) (map (lambda (f) (string-append "src/" f)) '("makewhatis.in" "man.conf" "paths.h" "version.h")))) #t)) (replace 'configure (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" ,(cc-for-target)) ;; Humor the manually written configure script. (invoke "./configure" "+lang" "en" "+fhs" (string-append "-prefix=" (assoc-ref outputs "out"))) #t))))) (home-page "https://www.kylheku.com/cgit/man/") (synopsis "Modifications to the man utilities, specifically man2html") (description "This is a fork of the man utilities intended specifically for building the HTML documentation of TXR.") (license license:gpl2)))) (define-public txr (package (name "txr") (version "298") (source (origin (method git-fetch) (uri (git-reference (url "https://www.kylheku.com/git/txr/") (commit (string-append "txr-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1y2g3dn47df781alfqaiak0nqkzv73yiaiypdd0q2gki9vriam1m")))) (build-system gnu-build-system) (arguments (list #:configure-flags #~(list (string-append "cc=" #$(cc-for-target)) (string-append "--prefix=" #$output)) #:test-target "tests" #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-license-installation (lambda _ (substitute* "Makefile" (("INSTALL(,.*LICENSE,.*)\\$\\(datadir\\)" _ match) (string-append "INSTALL" match #$output "/share/doc/" #$name "-" #$version))))) (delete 'install-license-files) (add-after 'unpack 'fix-paths (lambda* (#:key inputs #:allow-other-keys) (substitute* "stream.c" (("/bin/sh") (search-input-file inputs "/bin/bash"))))) (add-after 'unpack 'fix-tests (lambda _ (substitute* (list "tests/017/realpath.tl" "tests/017/realpath.expected") (("/usr/bin") "/")))) (replace 'configure ;; ./configure is a hand-written script that can't handle ;; standard autotools arguments like CONFIG_SHELL. (lambda* (#:key configure-flags #:allow-other-keys) (setenv "txr_shell" (which "bash")) (apply invoke "./configure" configure-flags))) (add-after 'build 'build-doc (lambda _ (setenv "GS_GENERATE_UUIDS" "0") (invoke "make" "txr-manpage.html" "txr-manpage.pdf"))) (add-after 'install 'install-doc (lambda _ (let ((doc (string-append #$output "/share/doc/" #$name "-" #$version))) (for-each (lambda (f) (install-file f doc)) '("txr-manpage.html" "txr-manpage.pdf"))))) (add-after 'install 'install-vim-files (lambda _ (let ((syntax (string-append #$output "/share/vim/vimfiles/pack/guix/start/txr/syntax"))) (install-file "tl.vim" syntax) (install-file "txr.vim" syntax))))))) (native-inputs ;; Required to build the documentation. (list ghostscript groff man-for-txr)) (inputs (list bash-minimal libffi libxcrypt zlib)) (synopsis "General-purpose, multi-paradigm programming language") (description "TXR is a general-purpose, multi-paradigm programming language. It comprises two languages integrated into a single tool: a text scanning and extraction language referred to as the TXR Pattern Language (sometimes just \"TXR\"), and a general-purpose dialect of Lisp called TXR Lisp. TXR can be used for everything from \"one liner\" data transformation tasks at the command line, to data scanning and extracting scripts, to full application development in a wide-range of areas.") (home-page "https://www.nongnu.org/txr/") (license license:bsd-2)))