inkscape.scm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. ;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
  11. ;;;
  12. ;;; This file is part of GNU Guix.
  13. ;;;
  14. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  15. ;;; under the terms of the GNU General Public License as published by
  16. ;;; the Free Software Foundation; either version 3 of the License, or (at
  17. ;;; your option) any later version.
  18. ;;;
  19. ;;; GNU Guix is distributed in the hope that it will be useful, but
  20. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;;; GNU General Public License for more details.
  23. ;;;
  24. ;;; You should have received a copy of the GNU General Public License
  25. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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 gettext)
  39. #:use-module (gnu packages glib)
  40. #:use-module (gnu packages gnome)
  41. #:use-module (gnu packages graphics)
  42. #:use-module (gnu packages gtk)
  43. #:use-module (gnu packages imagemagick)
  44. #:use-module (gnu packages libreoffice)
  45. #:use-module (gnu packages maths)
  46. #:use-module (gnu packages perl)
  47. #:use-module (gnu packages pdf)
  48. #:use-module (gnu packages popt)
  49. #:use-module (gnu packages python)
  50. #:use-module (gnu packages python-web)
  51. #:use-module (gnu packages python-xyz)
  52. #:use-module (gnu packages xml)
  53. #:use-module (gnu packages ghostscript)
  54. #:use-module (gnu packages fontutils)
  55. #:use-module (gnu packages image)
  56. #:use-module (gnu packages pkg-config)
  57. #:use-module (srfi srfi-1))
  58. ;;; A variant of Inkscape intended to be bumped only on core-updates, to avoid
  59. ;;; rebuilding 2k+ packages through dblatex.
  60. (define-public inkscape/stable
  61. (hidden-package
  62. (package
  63. (name "inkscape")
  64. (version "1.2.1")
  65. (source
  66. (origin
  67. (method url-fetch)
  68. (uri (string-append "https://media.inkscape.org/dl/"
  69. "resources/file/"
  70. "inkscape-" version ".tar.xz"))
  71. (patches (search-patches "inkscape-poppler-compat.patch"))
  72. (sha256
  73. (base32 "06scilds4p4bw337ss22nfdxy2kynv5yjw6vq6nlpjm7xfh7vkj6"))
  74. (modules '((guix build utils)
  75. (ice-9 format)))
  76. (snippet
  77. '(begin
  78. (let-syntax
  79. ;; XXX: The build system doesn't currently support using
  80. ;; system libraries over bundled ones (see:
  81. ;; https://gitlab.com/inkscape/inkscape/issues/876).
  82. ((unbundle
  83. (syntax-rules ()
  84. ((_ (name source-dir use-pkg-config?) ...)
  85. (begin
  86. ;; Delete bundled source directories.
  87. (delete-file-recursively source-dir) ...
  88. (substitute* '("src/CMakeLists.txt"
  89. "src/3rdparty/CMakeLists.txt")
  90. (((string-append ".*add_subdirectory\\("
  91. (basename source-dir) "\\).*"))
  92. "") ...)
  93. ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
  94. (substitute* "src/CMakeLists.txt"
  95. (((string-append name "_LIB.*")) "") ...)
  96. ;; Register the external libraries, so that their
  97. ;; headers are added to INKSCAPE_INCS_SYS and their
  98. ;; shared libraries added to INKSCAPE_LIBS.
  99. (if use-pkg-config?
  100. (let* ((width (string-length "pkg_check_modules("))
  101. (indent (string-join (make-list width " ") "")))
  102. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  103. (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
  104. (string-append start
  105. (format #f "~a~a~%" indent name)))))
  106. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  107. (("^find_package\\(Iconv REQUIRED\\).*" start)
  108. (string-append (format #f "
  109. find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
  110. if(NOT ~:*~a_INCLUDE_DIR)
  111. message(FATAL_ERROR \"~:*~a headers not found\")
  112. else()
  113. list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
  114. endif()
  115. find_library(~:*~a_LIB NAMES ~:*~a)
  116. if(NOT ~:*~a_LIB)
  117. message(FATAL_ERROR \"~:*~a library not found\")
  118. else()
  119. list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
  120. endif()~%~%"
  121. name)
  122. start)))) ...
  123. ;; Fix the references to the headers of the
  124. ;; unbundled libraries.
  125. (substitute* (find-files "." "\\.h$|\\.cpp$")
  126. (((string-append "#include (\"|<)3rdparty/"
  127. (basename source-dir)) _ quote)
  128. (string-append "#include " quote
  129. (basename source-dir)))
  130. ...))))))
  131. (unbundle ("2geom" "src/3rdparty/2geom" #t)
  132. ;; libcroco cannot be unbundled as it is heavily
  133. ;; modified (see:
  134. ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
  135. ;; ("croco" "src/3rdparty/libcroco" #t)
  136. ;; FIXME: Unbundle the following libraries once they
  137. ;; have been packaged.
  138. ;; ("cola" "src/3rdparty/adaptagrams/libcola")
  139. ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
  140. ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
  141. ;; libuemf cannot be unbundled as it slightly modified
  142. ;; from upstream (see:
  143. ;; https://gitlab.com/inkscape/inkscape/issues/973).
  144. ;; ("uemf" "src/3rdparty/libuemf" #f)
  145. ;; FIXME: libdepixelize upstream is ancient and doesn't
  146. ;; build with a recent lib2geom
  147. ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
  148. ;;("depixelize" "src/3rdparty/libdepixelize")
  149. ("autotrace" "src/3rdparty/autotrace" #t)))
  150. ;; Lift the requirement on the double-conversion library, as
  151. ;; it is only needed by lib2geom, which is now unbundled.
  152. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  153. ((".*find_package\\(DoubleConversion.*") ""))))))
  154. (build-system cmake-build-system)
  155. (arguments
  156. `(#:test-target "check" ;otherwise some test binaries are missing
  157. #:imported-modules (,@%cmake-build-system-modules
  158. (guix build glib-or-gtk-build-system))
  159. #:modules ((guix build cmake-build-system)
  160. ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
  161. (guix build utils))
  162. #:phases
  163. (modify-phases %standard-phases
  164. (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
  165. (assoc-ref glib-or-gtk:%standard-phases
  166. 'generate-gdk-pixbuf-loaders-cache-file))
  167. (add-after 'unpack 'patch-icon-cache-generator
  168. (lambda _
  169. (substitute* "share/icons/application/CMakeLists.txt"
  170. (("gtk-update-icon-cache") "true"))))
  171. (add-after 'unpack 'disable-latex-export-tests
  172. ;; FIXME: For some reason the test.pdf_tex file generated by the
  173. ;; "--export-latex" lacks "some text" in its content when run in
  174. ;; the build environment. Skip the related tests.
  175. (lambda _
  176. (substitute* "testfiles/cli_tests/CMakeLists.txt"
  177. (("add_cli_test\\(export-latex")
  178. "message(TEST_DISABLED: export-latex"))))
  179. (add-after 'unpack 'disable-vertical-glyph-tests
  180. (lambda _
  181. ;; FIXME: These tests fail with newer Pango and Harfbuzz:
  182. ;; https://gitlab.com/inkscape/inkscape/-/issues/2917
  183. ;; https://gitlab.com/inkscape/inkscape/-/issues/3554
  184. ;; Simply providing older versions don't work, as we need
  185. ;; the full GTK stack; we could use package-input-rewriting
  186. ;; but then have to also downgrade pangomm and disable tests
  187. ;; in librsvg and GTK+. Just ignore for now.
  188. (substitute* "testfiles/rendering_tests/CMakeLists.txt"
  189. (("test-glyph-y-pos") "")
  190. (("text-glyphs-combining") "")
  191. (("text-glyphs-vertical") "")
  192. (("test-rtl-vertical") ""))))
  193. ,@(if (or (target-aarch64?)
  194. (target-ppc64le?)
  195. (target-riscv64?))
  196. `((add-after 'unpack 'disable-more-tests
  197. (lambda _
  198. ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035680690
  199. (substitute* "testfiles/CMakeLists.txt"
  200. (("lpe64-test") "#lpe64-test"))
  201. ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035539888
  202. ;; According to upstream, this is a false positive.
  203. (substitute* "testfiles/rendering_tests/CMakeLists.txt"
  204. (("test-use") "#test-use"))
  205. ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035539888
  206. ;; Allegedly a precision error in the gamma.
  207. (substitute* "testfiles/cli_tests/CMakeLists.txt"
  208. (("add_cli_test\\(export-png-color-mode-gray-8_png" all)
  209. (string-append "#" all))))))
  210. '())
  211. (add-after 'unpack 'set-home
  212. ;; Mute Inkscape warnings during tests.
  213. (lambda _
  214. (setenv "HOME" (getcwd))))
  215. ;; Move the check phase after the install phase, as when run in the
  216. ;; tests, Inkscape relies on files that are not yet installed, such
  217. ;; as the "share/inkscape/ui/units.xml" file.
  218. (delete 'check)
  219. (add-after 'install 'check
  220. (assoc-ref %standard-phases 'check))
  221. (add-after 'install 'glib-or-gtk-compile-schemas
  222. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
  223. (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
  224. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
  225. (add-after 'install 'wrap-program
  226. ;; Ensure Python is available at runtime.
  227. (lambda* (#:key outputs #:allow-other-keys)
  228. (let ((out (assoc-ref outputs "out")))
  229. (wrap-program (string-append out "/bin/inkscape")
  230. `("GUIX_PYTHONPATH" prefix
  231. (,(getenv "GUIX_PYTHONPATH")))
  232. ;; Wrapping GDK_PIXBUF_MODULE_FILE allows Inkscape to load
  233. ;; its own icons in pure environments.
  234. `("GDK_PIXBUF_MODULE_FILE" =
  235. (,(getenv "GDK_PIXBUF_MODULE_FILE"))))))))))
  236. (inputs
  237. (list aspell
  238. autotrace
  239. bash-minimal
  240. gdl-minimal
  241. gtkmm-3
  242. gtk+
  243. gtkspell3
  244. gsl
  245. poppler
  246. lib2geom
  247. libjpeg-turbo
  248. libpng
  249. libxml2
  250. libxslt
  251. libgc
  252. (librsvg-for-system) ;for the pixbuf loader
  253. libsoup-minimal-2
  254. libcdr
  255. libvisio
  256. libwpd
  257. libwpg
  258. freetype
  259. popt
  260. potrace
  261. lcms
  262. boost
  263. python-wrapper
  264. python-scour
  265. python-pyserial
  266. python-numpy
  267. python-lxml))
  268. (native-inputs
  269. (list gettext-minimal
  270. imagemagick ;for tests
  271. `(,glib "bin")
  272. googletest
  273. perl
  274. pkg-config))
  275. (home-page "https://inkscape.org/")
  276. (synopsis "Vector graphics editor")
  277. (description "Inkscape is a vector graphics editor. What sets Inkscape
  278. apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
  279. as the native format.")
  280. (license license:gpl3+)))) ;see the file COPYING
  281. (define-public inkscape
  282. (package
  283. (inherit inkscape/stable)
  284. (name "inkscape")
  285. (version "1.2.1")
  286. (source
  287. (origin
  288. (inherit (package-source inkscape/stable))
  289. (method url-fetch)
  290. (uri (string-append "https://media.inkscape.org/dl/"
  291. "resources/file/"
  292. "inkscape-" version ".tar.xz"))
  293. (sha256
  294. (base32 "06scilds4p4bw337ss22nfdxy2kynv5yjw6vq6nlpjm7xfh7vkj6"))))
  295. (build-system cmake-build-system)
  296. (arguments
  297. (substitute-keyword-arguments (package-arguments inkscape/stable)
  298. ((#:phases phases)
  299. `(modify-phases ,phases
  300. (replace 'wrap-program
  301. ;; Ensure Python is available at runtime.
  302. (lambda* (#:key outputs #:allow-other-keys)
  303. (let ((out (assoc-ref outputs "out")))
  304. (wrap-program (string-append out "/bin/inkscape")
  305. `("GUIX_PYTHONPATH" prefix
  306. (,(getenv "GUIX_PYTHONPATH")))
  307. ;; Wrapping GDK_PIXBUF_MODULE_FILE allows Inkscape to load
  308. ;; its own icons in pure environments.
  309. `("GDK_PIXBUF_MODULE_FILE" =
  310. (,(getenv "GDK_PIXBUF_MODULE_FILE")))))))))))
  311. (inputs (modify-inputs (package-inputs inkscape/stable)
  312. (append python-cssselect))) ;to render qrcode
  313. (properties (alist-delete 'hidden? (package-properties inkscape/stable)))))