projects/guix·blob python-team · refs

539 lines · 20.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2015, 2021, 2023 Ludovic Courtès <[email protected]>
3;;; Copyright © 2015, 2020 Efraim Flashner <[email protected]>
4;;; Copyright © 2016 Theodoros Foradis <[email protected]>
5;;; Copyright © 2017, 2018, 2019, 2022 Ricardo Wurmus <[email protected]>
6;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2017 Gábor Boskovits <[email protected]>
8;;; Copyright © 2018 Mathieu Lirzin <[email protected]>
9;;; Copyright © 2020, 2022 Marius Bakke <[email protected]>
10;;; Copyright © 2020 Vincent Legoll <[email protected]>
11;;; Copyright © 2020 Pjotr Prins <[email protected]>
12;;; Copyright © 2021 Bonface Munyoki Kilyungi <[email protected]>
13;;; Copyright © 2021 Giacomo Leidi <[email protected]>
14;;; Copyright © 2021 Justin Veilleux <[email protected]>
15;;; Copyright © 2021 Denis 'GNUtoo' Carikli <[email protected]>
16;;; Copyright © 2024 Artyom V. Poptsov <[email protected]>
17;;; Copyright © 2025 Zheng Junjie <[email protected]>
18;;;
19;;; This file is part of GNU Guix.
20;;;
21;;; GNU Guix is free software; you can redistribute it and/or modify it
22;;; under the terms of the GNU General Public License as published by
23;;; the Free Software Foundation; either version 3 of the License, or (at
24;;; your option) any later version.
25;;;
26;;; GNU Guix is distributed in the hope that it will be useful, but
27;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29;;; GNU General Public License for more details.
30;;;
31;;; You should have received a copy of the GNU General Public License
32;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34(define-module (gnu packages graphviz)
35 #:use-module (guix packages)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system pyproject)
38 #:use-module (guix download)
39 #:use-module (guix git-download)
40 #:use-module (guix utils)
41 #:use-module (guix gexp)
42 #:use-module (gnu packages)
43 #:use-module (gnu packages autotools)
44 #:use-module (gnu packages bash)
45 #:use-module (gnu packages bison)
46 #:use-module (gnu packages check)
47 #:use-module (gnu packages compression)
48 #:use-module (gnu packages fontutils)
49 #:use-module (gnu packages gd)
50 #:use-module (gnu packages gl)
51 #:use-module (gnu packages glib)
52 #:use-module (gnu packages gnome)
53 #:use-module (gnu packages gtk)
54 #:use-module (gnu packages guile)
55 #:use-module (gnu packages image)
56 #:use-module (gnu packages pkg-config)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages python-build)
59 #:use-module (gnu packages python-check)
60 #:use-module (gnu packages python-xyz)
61 #:use-module (gnu packages sphinx)
62 #:use-module (gnu packages swig)
63 #:use-module (gnu packages tex)
64 #:use-module (gnu packages vulkan)
65 #:use-module (gnu packages xml)
66 #:use-module (gnu packages xorg)
67 #:use-module ((guix licenses) #:prefix license:))
68
69(define-public graphviz
70 (package
71 (name "graphviz")
72 (version "7.0.1")
73 (source (origin
74 (method url-fetch)
75 (uri (string-append "https://gitlab.com/api/v4/projects/4207231"
76 "/packages/generic/graphviz-releases/"
77 version "/graphviz-" version ".tar.xz"))
78 (sha256
79 (base32
80 "1b6x3g03j7q77lzyvdp34hkzld5sg1l1ippc6sh1qxnmm59xs3ly"))))
81 (build-system gnu-build-system)
82 (arguments
83 ;; FIXME: rtest/rtest.sh is a ksh script (!). Add ksh as an input.
84 (list #:tests? #f
85 #:phases
86 #~(modify-phases %standard-phases
87 (add-after 'install 'move-guile-bindings
88 (lambda* (#:key outputs #:allow-other-keys)
89 (let* ((lib (string-append #$output "/lib"))
90 (extdir (string-append lib "/guile/"
91 #$(version-major+minor
92 (package-version
93 (this-package-input "guile")))
94 "/extensions")))
95 (mkdir-p extdir)
96 (rename-file (string-append
97 lib "/graphviz/guile/libgv_guile.so")
98 (string-append extdir
99 "/libgv_guile.so"))))))))
100 (inputs
101 (list libxrender
102 libx11
103 gts
104 gd
105 guile-3.0 ;Guile bindings
106 pango
107 fontconfig
108 freetype
109 libltdl
110 libxaw
111 expat
112 libjpeg-turbo
113 libpng))
114 (native-inputs
115 (list bison
116 pkg-config
117 swig-4.0))
118 (outputs '("out" "doc")) ;5 MiB of html + pdfs
119 (home-page "https://www.graphviz.org/")
120 (synopsis "Graph visualization software")
121 (description
122 "Graphviz is a graph visualization tool suite. Graph visualization is a
123way of representing structural information as diagrams of abstract graphs and
124networks. It has important applications in networking, bioinformatics,
125software engineering, database and web design, machine learning, and in visual
126interfaces for other technical domains.")
127 (properties
128 '((release-monitoring-url . "https://graphviz.org/download/source/")))
129 (license license:epl1.0)))
130
131(define-public graphviz-14
132 (package
133 (inherit graphviz)
134 (version "14.1.1")
135 (source (origin
136 (method url-fetch)
137 (uri (string-append "https://gitlab.com/api/v4/projects/4207231"
138 "/packages/generic/graphviz-releases/"
139 version "/graphviz-" version ".tar.xz"))
140 (sha256
141 (base32
142 "1c9nip42l4z9cprxbqkd39hbl74hzvzvrc06ghdnxfd5686dp1m7"))))))
143
144(define-public graphviz-minimal
145 (package/inherit graphviz
146 (name "graphviz-minimal")
147 (inputs (modify-inputs inputs
148 (delete "libxrender" "libx11" "pango" "libxaw")))
149 (synopsis "Graph visualization software (without X11 support)")))
150
151(define-public python-graphviz
152 (package
153 (name "python-graphviz")
154 (version "0.21")
155 (source
156 (origin
157 (method git-fetch)
158 (uri (git-reference
159 (url "https://github.com/xflr6/graphviz")
160 (commit version)))
161 (file-name (git-file-name name version))
162 (sha256
163 (base32 "00hgh1ab54h2jhqnwn5vrggg0hqbwmjn0cx2a9nw4vi1wmijib53"))))
164 (build-system pyproject-build-system)
165 (arguments
166 (list
167 #:test-flags
168 #~(list "--ignore=tests/backend/")
169 #:phases
170 #~(modify-phases %standard-phases
171 (add-after 'unpack 'patch-pytest-options
172 (lambda _
173 (substitute* "pyproject.toml"
174 ((".*--cov-report=term.*") ""))))
175 (add-before 'check 'pre-check
176 (lambda _
177 (setenv "HOME" "/tmp")))
178 (add-after 'check 'test-backend
179 (lambda* (#:key tests? #:allow-other-keys)
180 ;; Running tests together fails with error:
181 ;;
182 ;; import file mismatch:
183 ;; imported module 'conftest' has this __file__ attribute:
184 ;; /<...>/source/tests/backend/conftest.py
185 ;; which is not the same as the test file we want to collect:
186 ;; /<...>/source/tests/conftest.py
187 ;;
188 ;; HINT: remove __pycache__ / .pyc files and/or use a unique
189 ;; basename for your test file modules
190 (when tests?
191 (invoke "pytest" "-v" "tests/backend/")))))))
192 (native-inputs
193 (list graphviz
194 python-mock
195 python-pytest
196 python-pytest-mock
197 python-setuptools))
198 (home-page "https://github.com/xflr6/graphviz")
199 (synopsis "Simple Python interface for Graphviz")
200 (description
201 "This package provides a simple Python interface for the Graphviz graph
202visualization tool suite.")
203 (license license:expat)))
204
205(define-public python-pygraphviz
206 (package
207 (name "python-pygraphviz")
208 (version "1.14")
209 (source
210 (origin
211 (method git-fetch)
212 (uri (git-reference
213 (url "https://github.com/pygraphviz/pygraphviz")
214 (commit (string-append "pygraphviz-" version))))
215 (file-name (string-append "pygraphviz-" version "-checkout"))
216 (sha256
217 (base32 "03q6k030nvrl30a86bgnjqjh1csh8zpw8dkgajkn33v3cx7jc9a7"))))
218 (build-system pyproject-build-system)
219 (arguments
220 (list
221 #:test-flags #~(list "--pyargs" "pygraphviz")))
222 (native-inputs
223 (list python-mock
224 python-pytest
225 python-setuptools
226 python-wheel))
227 (inputs
228 (list graphviz))
229 (home-page "https://pygraphviz.github.io")
230 (synopsis "Python interface to Graphviz")
231 (description
232 "PyGraphviz is a Python interface to the Graphviz graph layout and
233visualization package. With PyGraphviz you can create, edit, read, write, and
234draw graphs using Python to access the Graphviz graph data structure and
235layout algorithms.")
236 (license license:bsd-3)))
237
238(define-public python-uqbar
239 (package
240 (name "python-uqbar")
241 (version "0.9.6")
242 (source
243 (origin
244 (method git-fetch)
245 (uri (git-reference
246 (url "https://github.com/josiah-wolf-oberholtzer/uqbar")
247 (commit (string-append "v" version))))
248 (file-name (git-file-name name version))
249 (sha256
250 (base32 "07crragfc2y20kh3b2ig4q6725k1l9pnnqkqcn88kp8rbk9bicnn"))))
251 (build-system pyproject-build-system)
252 (arguments
253 (list
254 #:test-flags
255 #~(list "--pyargs" "uqbar"
256 ;; Diffs are not equal.
257 "-k" "not uqbar.apis.summarizers.SummarizingRootDocumenter")))
258 (native-inputs
259 (list graphviz
260 python-defusedxml
261 python-pytest
262 python-setuptools
263 python-typing-extensions))
264 (propagated-inputs
265 (list python-black
266 python-sphinx
267 python-unidecode))
268 (home-page "https://github.com/josiah-wolf-oberholtzer/uqbar")
269 (synopsis "Tools for building documentation with Sphinx, Graphviz and LaTeX")
270 (description
271 "This package contains tools for building documentation with Sphinx,
272Graphviz and LaTeX.")
273 (license license:expat)))
274
275(define-public gts
276 (package
277 (name "gts")
278 (version "0.7.6")
279 (source (origin
280 (method url-fetch)
281 (uri (string-append "mirror://sourceforge/gts/gts/" version
282 "/gts-" version ".tar.gz"))
283 (sha256
284 (base32
285 "07mqx09jxh8cv9753y2d2jsv7wp8vjmrd7zcfpbrddz3wc9kx705"))))
286 (build-system gnu-build-system)
287 (arguments
288 `(,@(if (%current-target-system)
289 `(#:configure-flags
290 (list (string-append
291 "PKG_CONFIG="
292 (search-input-file
293 %build-inputs
294 (string-append "/bin/" ,(pkg-config-for-target))))))
295 '())
296 #:phases
297 (modify-phases %standard-phases
298 (add-before 'check 'pre-check
299 (lambda _
300 (chmod "test/boolean/test.sh" #o777)
301 #t))
302 ,@(if (%current-target-system)
303 `((add-after 'unpack 'update-config
304 (lambda* (#:key native-inputs inputs #:allow-other-keys)
305 (for-each (lambda (file)
306 (install-file
307 (search-input-file
308 (or native-inputs inputs)
309 (string-append "/bin/" file)) "."))
310 '("config.guess" "config.sub"))))
311 (add-after 'unpack 'fix-predicates_init
312 (lambda _
313 (substitute* "src/Makefile.in"
314 (("\\$[(]COMPILE[)] \\$[(]srcdir[)]/predicates_init\\.c\
315 -o \\$[(]srcdir[)]/predicates_init")
316 "gcc $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
317$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(srcdir)/predicates_init.c \
318-o $(srcdir)/predicates_init")))))
319 '()))
320
321 ;; Some data files used by the test suite are missing.
322 ;; See <http://sourceforge.net/p/gts/bugs/41/>.
323 #:tests? #f))
324 (native-inputs
325 (append (if (%current-target-system)
326 (list config)
327 '())
328 (list pkg-config)))
329 (propagated-inputs
330 ;; The gts.pc file has glib-2.0 as required.
331 (list glib))
332 (home-page "https://gts.sourceforge.net/")
333
334 ;; Note: Despite the name, this is not official GNU software.
335 (synopsis "Triangulated Surface Library")
336 (description
337 "Library intended to provide a set of useful functions to deal with
3383D surfaces meshed with interconnected triangles.")
339 (license license:lgpl2.0+)))
340
341(define-public xdot
342 (package
343 (name "xdot")
344 (version "1.6")
345 (source
346 (origin
347 ;; PyPI tarball is missing some test files.
348 (method git-fetch)
349 (uri (git-reference
350 (url "https://github.com/jrfonseca/xdot.py/")
351 (commit version)))
352 (file-name (git-file-name name version))
353 (sha256
354 (base32 "0gg54k6zhdviz17aa3harc82f7bx4mpwnj292q066dzamvr87svq"))))
355 (build-system pyproject-build-system)
356 (arguments
357 (list
358 #:phases #~(modify-phases %standard-phases
359 (add-before 'build 'start-xserver
360 (lambda* (#:key inputs native-inputs #:allow-other-keys)
361 (let ((Xvfb (search-input-file (or native-inputs inputs)
362 "/bin/Xvfb")))
363 (system (format #f "~a :1 -screen 0 640x480x24 &"
364 Xvfb))
365 (setenv "DISPLAY" ":1"))))
366 (add-before 'check 'set-test-environment
367 (lambda* (#:key inputs #:allow-other-keys)
368 (let ((lib (search-input-file inputs
369 "lib/libvulkan.so.1")))
370 (setenv "XDG_RUNTIME_DIR"
371 (getcwd))
372 (setenv "LIBGL_ALWAYS_SOFTWARE" "1")
373 (format (current-error-port) "~a~%"
374 (assoc-ref inputs "gtk+"))
375 (setenv "LD_LIBRARY_PATH"
376 (dirname lib)))))
377 ;; We wrap xdot, so that we don't propagate gtk+ and graphviz
378 (replace 'wrap
379 (lambda* (#:key inputs outputs #:allow-other-keys)
380 (let ((graphviz (assoc-ref inputs "graphviz"))
381 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
382 (python-path (getenv "GUIX_PYTHONPATH")))
383 (wrap-program (string-append #$output "/bin/xdot")
384 `("PATH" ":" prefix
385 (,(string-append graphviz "/bin")))
386 `("GI_TYPELIB_PATH" ":" prefix
387 (,gi-typelib-path))
388 `("GUIX_PYTHONPATH" ":" prefix
389 (,python-path))))))
390 (replace 'check
391 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
392 (when tests?
393 (add-installed-pythonpath inputs outputs)
394 (invoke "python" "test.py")))))))
395 (native-inputs (list gobject-introspection xorg-server-for-tests
396 python-packaging))
397 (inputs (list at-spi2-core
398 bash-minimal
399 (librsvg-for-system)
400 mesa
401 mesa-opencl
402 harfbuzz
403 graphviz
404 gtk+
405 python-numpy
406 python-pycairo
407 python-pygobject
408 python-setuptools
409 python-wheel
410 vulkan-loader))
411 (home-page "https://pypi.org/project/xdot/")
412 (synopsis "Interactive viewer for graphviz dot files")
413 (description
414 "Xdot is an interactive viewer for graphs written in
415@code{graphviz}’s dot language. Internally, it uses the xdot output format as
416an intermediate format, and @code{gtk} and @code{cairo} for rendering. Xdot
417can be used either as a standalone application, or as a Python library.")
418 (license license:lgpl3+)))
419
420(define-public python-pydot
421 (package
422 (name "python-pydot")
423 (version "4.0.1")
424 (source
425 (origin
426 (method url-fetch)
427 (uri (pypi-uri "pydot" version))
428 (sha256
429 (base32
430 "1maa6rvnbs1cyfc801ia1qpai6a0irgrwsp2y25y0csa3il8y562"))))
431 (build-system pyproject-build-system)
432 (native-inputs
433 (list graphviz
434 python-chardet
435 python-parameterized
436 python-pytest
437 python-pytest-xdist
438 python-setuptools))
439 (propagated-inputs
440 (list python-pyparsing))
441 (home-page "https://github.com/pydot/pydot")
442 (synopsis "Python interface to Graphviz's DOT language")
443 (description
444 "Pydot provides an interface to create, handle, modify and process
445graphs in Graphviz's DOT language, written in pure Python.")
446 (license license:expat)))
447
448(define-public dot2tex
449 (package
450 (name "dot2tex")
451 (version "2.11.3")
452 (source (origin
453 (method url-fetch)
454 (uri (pypi-uri "dot2tex" version))
455 (sha256
456 (base32
457 "1kp77wiv7b5qib82i3y3sn9r49rym43aaqm5aw1bwnzfbbq2m6i9"))))
458 (build-system pyproject-build-system)
459 (arguments
460 (list
461 ;; tests: 57 passed, 1 deselected
462 #:test-flags
463 ;; The test_semicolon test fails for unknown reason, see:
464 ;; <https://github.com/kjellmf/dot2tex/issues/94>.
465 #~(list "--deselect=tests/test_dot2tex.py::MultipleStatements::test_semicolon")))
466 (native-inputs
467 (list python-pytest
468 python-setuptools
469 (texlive-local-tree
470 (list texlive-pgf
471 texlive-preview
472 texlive-pstricks
473 texlive-xcolor
474 texlive-xkeyval))))
475 (inputs (list graphviz))
476 (propagated-inputs (list python-pyparsing))
477 (home-page "https://github.com/kjellmf/dot2tex")
478 (synopsis "Graphviz to LaTeX converter")
479 (description
480 "The purpose of @code{dot2tex} is to give graphs generated by Graphviz a
481more LaTeX friendly look and feel. This is accomplished by converting
482@code{xdot} output from Graphviz to a series of PSTricks or PGF/TikZ commands.
483This approach allows:
484
485@itemize @bullet
486@item Typesetting labels with LaTeX, allowing mathematical notation
487@item Using native PSTricks and PGF/TikZ commands for drawing arrows
488@item Using backend specific styles to customize the output
489@end itemize")
490 (license license:expat)))
491
492(define-public gprof2dot
493 (package
494 (name "gprof2dot")
495 (version "2025.04.14")
496 (source
497 (origin
498 (method git-fetch)
499 (uri (git-reference
500 (url "https://github.com/jrfonseca/gprof2dot")
501 (commit version)))
502 (file-name (git-file-name name version))
503 (sha256
504 (base32 "0yil32pbcarwsfmhgn2zhldjj985v9p80f2yi2shkaxzfc4w6zwi"))))
505 (build-system pyproject-build-system)
506 (arguments
507 (list
508 #:test-backend #~'custom
509 #:test-flags
510 #~(list "tests/test.py"
511 "--python=bash"
512 "--max-acceptable=0"
513 (string-append "--gprof2dot=" #$output "/bin/gprof2dot"))
514 #:phases
515 #~(modify-phases %standard-phases
516 (add-before 'check 'pre-tests
517 ;; Prevent irrelevant errors that cause test output mismatches:
518 ;; ‘Fontconfig error: No writable cache directories’
519 (lambda _
520 (setenv "XDG_CACHE_HOME" "/tmp"))))))
521 (native-inputs
522 (list graphviz
523 python-setuptools))
524 (home-page "https://github.com/jrfonseca/gprof2dot")
525 (synopsis "Generate a dot graph from the output of several profilers")
526 (description "This package provides a Python script to convert the output
527from many profilers into a dot graph.
528
529It can:
530
531@itemize
532
533@item prune nodes and edges below a certain threshold;
534@item use an heuristic to propagate time inside mutually recursive functions;
535@item use color efficiently to draw attention to hot-spots;
536@item work on any platform where Python and Graphviz is available.
537
538@end itemize")
539 (license license:lgpl3+)))