gnu: inkscape: Update to 1.2.1.
[jackhill/guix/guix.git] / gnu / packages / inkscape.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2018 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2017, 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2020 Boris A. Dekshteyn <boris.dekshteyn@gmail.com>
9 ;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages inkscape)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix utils)
31 #:use-module (guix build-system cmake)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages aspell)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages bdw-gc)
36 #:use-module (gnu packages boost)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages glib)
39 #:use-module (gnu packages gnome)
40 #:use-module (gnu packages graphics)
41 #:use-module (gnu packages gtk)
42 #:use-module (gnu packages imagemagick)
43 #:use-module (gnu packages libreoffice)
44 #:use-module (gnu packages maths)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages pdf)
47 #:use-module (gnu packages popt)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages python-xyz)
50 #:use-module (gnu packages xml)
51 #:use-module (gnu packages ghostscript)
52 #:use-module (gnu packages fontutils)
53 #:use-module (gnu packages image)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (srfi srfi-1))
56
57 ;;; A variant of Inkscape intended to be bumped only on core-updates, to avoid
58 ;;; rebuilding 2k+ packages through dblatex.
59 (define-public inkscape/stable
60 (hidden-package
61 (package
62 (name "inkscape")
63 (version "1.1.1")
64 (source
65 (origin
66 (method url-fetch)
67 (uri (string-append "https://media.inkscape.org/dl/"
68 "resources/file/"
69 "inkscape-" version ".tar.xz"))
70 (sha256
71 (base32 "1bvqg5xfs3m6r7qfdhmgzwhd1hx8wvg3nhvhmalwzcdm6ffhpjmf"))
72 (modules '((guix build utils)
73 (ice-9 format)))
74 (snippet
75 '(begin
76 (let-syntax
77 ;; XXX: The build system doesn't currently support using
78 ;; system libraries over bundled ones (see:
79 ;; https://gitlab.com/inkscape/inkscape/issues/876).
80 ((unbundle
81 (syntax-rules ()
82 ((_ (name source-dir use-pkg-config?) ...)
83 (begin
84 ;; Delete bundled source directories.
85 (delete-file-recursively source-dir) ...
86 (substitute* '("src/CMakeLists.txt"
87 "src/3rdparty/CMakeLists.txt")
88 (((string-append ".*add_subdirectory\\("
89 (basename source-dir) "\\).*"))
90 "") ...)
91 ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
92 (substitute* "src/CMakeLists.txt"
93 (((string-append name "_LIB.*")) "") ...)
94 ;; Register the external libraries, so that their
95 ;; headers are added to INKSCAPE_INCS_SYS and their
96 ;; shared libraries added to INKSCAPE_LIBS.
97 (if use-pkg-config?
98 (let* ((width (string-length "pkg_check_modules("))
99 (indent (string-join (make-list width " ") "")))
100 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
101 (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
102 (string-append start
103 (format #f "~a~a~%" indent name)))))
104 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
105 (("^find_package\\(Iconv REQUIRED\\).*" start)
106 (string-append (format #f "
107 find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
108 if(NOT ~:*~a_INCLUDE_DIR)
109 message(FATAL_ERROR \"~:*~a headers not found\")
110 else()
111 list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
112 endif()
113
114 find_library(~:*~a_LIB NAMES ~:*~a)
115 if(NOT ~:*~a_LIB)
116 message(FATAL_ERROR \"~:*~a library not found\")
117 else()
118 list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
119 endif()~%~%"
120 name)
121 start)))) ...
122 ;; Fix the references to the headers of the
123 ;; unbundled libraries.
124 (substitute* (find-files "." "\\.h$|\\.cpp$")
125 (((string-append "#include (\"|<)3rdparty/"
126 (basename source-dir)) _ quote)
127 (string-append "#include " quote
128 (basename source-dir)))
129 ...))))))
130 (unbundle ("2geom" "src/3rdparty/2geom" #t)
131 ;; libcroco cannot be unbundled as it is heavily
132 ;; modified (see:
133 ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
134 ;; ("croco" "src/3rdparty/libcroco" #t)
135 ;; FIXME: Unbundle the following libraries once they
136 ;; have been packaged.
137 ;; ("cola" "src/3rdparty/adaptagrams/libcola")
138 ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
139 ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
140 ;; libuemf cannot be unbundled as it slightly modified
141 ;; from upstream (see:
142 ;; https://gitlab.com/inkscape/inkscape/issues/973).
143 ;; ("uemf" "src/3rdparty/libuemf" #f)
144 ;; FIXME: libdepixelize upstream is ancient and doesn't
145 ;; build with a recent lib2geom
146 ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
147 ;;("depixelize" "src/3rdparty/libdepixelize")
148 ("autotrace" "src/3rdparty/autotrace" #t)))
149 ;; Lift the requirement on the double-conversion library, as
150 ;; it is only needed by lib2geom, which is now unbundled.
151 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
152 ((".*find_package\\(DoubleConversion.*") ""))))))
153 (build-system cmake-build-system)
154 (arguments
155 `(#:test-target "check" ;otherwise some test binaries are missing
156 #:imported-modules (,@%cmake-build-system-modules
157 (guix build glib-or-gtk-build-system))
158 #:modules ((guix build cmake-build-system)
159 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
160 (guix build utils))
161 #:phases
162 (modify-phases %standard-phases
163 (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
164 (assoc-ref glib-or-gtk:%standard-phases
165 'generate-gdk-pixbuf-loaders-cache-file))
166 (add-after 'unpack 'patch-icon-cache-generator
167 (lambda _
168 (substitute* "share/icons/application/CMakeLists.txt"
169 (("gtk-update-icon-cache") "true"))))
170 (add-after 'unpack 'disable-latex-export-tests
171 ;; FIXME: For some reason the test.pdf_tex file generated by the
172 ;; "--export-latex" lacks "some text" in its content when run in
173 ;; the build environment. Skip the related tests.
174 (lambda _
175 (substitute* "testfiles/cli_tests/CMakeLists.txt"
176 (("add_cli_test\\(export-latex")
177 "message(TEST_DISABLED: export-latex"))))
178 (add-after 'unpack 'set-home
179 ;; Mute Inkscape warnings during tests.
180 (lambda _
181 (setenv "HOME" (getcwd))))
182 ;; Move the check phase after the install phase, as when run in the
183 ;; tests, Inkscape relies on files that are not yet installed, such
184 ;; as the "share/inkscape/ui/units.xml" file.
185 (delete 'check)
186 (add-after 'install 'check
187 (assoc-ref %standard-phases 'check))
188 (add-after 'install 'glib-or-gtk-compile-schemas
189 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
190 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
191 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
192 (add-after 'install 'wrap-program
193 ;; Ensure Python is available at runtime.
194 (lambda* (#:key outputs #:allow-other-keys)
195 (let ((out (assoc-ref outputs "out")))
196 (wrap-program (string-append out "/bin/inkscape")
197 `("GUIX_PYTHONPATH" ":" prefix
198 (,(getenv "GUIX_PYTHONPATH"))))))))))
199 (inputs
200 `(("aspell" ,aspell)
201 ("autotrace" ,autotrace)
202 ("gdl" ,gdl-minimal)
203 ("gtkmm" ,gtkmm-3)
204 ("gtk" ,gtk+)
205 ("gtkspell3" ,gtkspell3)
206 ("gsl" ,gsl)
207 ("poppler" ,poppler)
208 ("lib2geom" ,lib2geom)
209 ("libjpeg" ,libjpeg-turbo)
210 ("libpng" ,libpng)
211 ("libxml2" ,libxml2)
212 ("libxslt" ,libxslt)
213 ("libgc" ,libgc)
214 ("libsoup" ,libsoup-minimal-2)
215 ("libcdr" ,libcdr)
216 ("libvisio" ,libvisio)
217 ("libwpd" ,libwpd)
218 ("libwpg" ,libwpg)
219 ("freetype" ,freetype)
220 ("popt" ,popt)
221 ("potrace" ,potrace)
222 ("lcms" ,lcms)
223 ("boost" ,boost)
224 ("python" ,python-wrapper)
225 ("python-scour" ,python-scour)
226 ("python-pyserial" ,python-pyserial)
227 ("python-numpy" ,python-numpy)
228 ("python-lxml" ,python-lxml)))
229 (native-inputs
230 (list imagemagick ;for tests
231 intltool
232 `(,glib "bin")
233 googletest
234 perl
235 pkg-config))
236 (home-page "https://inkscape.org/")
237 (synopsis "Vector graphics editor")
238 (description "Inkscape is a vector graphics editor. What sets Inkscape
239 apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
240 as the native format.")
241 (license license:gpl3+)))) ;see the file COPYING
242
243 (define-public inkscape
244 (package
245 (inherit inkscape/stable)
246 (name "inkscape")
247 (version "1.2.1")
248 (source
249 (origin
250 (inherit (package-source inkscape/stable))
251 (method url-fetch)
252 (uri (string-append "https://media.inkscape.org/dl/"
253 "resources/file/"
254 "inkscape-" version ".tar.xz"))
255 (sha256
256 (base32 "06scilds4p4bw337ss22nfdxy2kynv5yjw6vq6nlpjm7xfh7vkj6"))))
257 (build-system cmake-build-system)
258 (arguments
259 (substitute-keyword-arguments (package-arguments inkscape/stable)
260 ((#:phases phases)
261 `(modify-phases ,phases
262 (add-after 'unpack 'disable-problematic-tests
263 ;; The UnionOutside and UnionOutsideSwap tests fail, comparing
264 ;; e.g. the result "M 0 1.5 V 0 H 2 V 2 H 0.5 V 2.5 H 0 V 2 V 1.5 H
265 ;; 0.5 V 2 z" to the expected string "M 0 0 V 1.5 V 2 V 2.5 H 0.5 V
266 ;; 2 H 2 V 0 z" (see:
267 ;; https://gitlab.com/inkscape/inkscape/-/issues/3689).
268 (lambda _
269 (substitute* "testfiles/src/path-boolop-test.cpp"
270 (("PathBoolopTest, UnionOutside(Swap)?.*" all)
271 (string-append all " GTEST_SKIP();\n")))))
272 (replace 'wrap-program
273 ;; Ensure Python is available at runtime.
274 (lambda* (#:key outputs #:allow-other-keys)
275 (let ((out (assoc-ref outputs "out")))
276 (wrap-program (string-append out "/bin/inkscape")
277 `("GUIX_PYTHONPATH" prefix
278 (,(getenv "GUIX_PYTHONPATH")))
279 ;; Wrapping GDK_PIXBUF_MODULE_FILE allows Inkscape to load
280 ;; its own icons in pure environments.
281 `("GDK_PIXBUF_MODULE_FILE" =
282 (,(getenv "GDK_PIXBUF_MODULE_FILE")))))))))))
283 (inputs (modify-inputs (package-inputs inkscape/stable)
284 (append bash-minimal
285 librsvg))) ;for the pixbuf loader
286 (properties (alist-delete 'hidden? (package-properties inkscape/stable)))))