gnu: unoconv: Switch to pyproject.

* gnu/packages/libreoffice.scm (unoconv):
[build-system]: Switch to pyproject-build-system.
[arguments]<#:phases>: Add 'check phase replacement.
[native-inputs]: Add gnu-make, python-setuptools.

Change-Id: I2a8c35fddcc9af4a51c0414feea8a74261b37de2
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2025-11-23 22:43:16 +01:00 committed by Sharlatan Hellseher
parent 56bd65a410
commit d3600a04c9
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -36,6 +36,7 @@
#:use-module (guix build-system glib-or-gtk)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
#:use-module (guix build-system pyproject)
#:use-module (guix gexp)
#:use-module (guix download)
#:use-module (guix git-download)
@ -87,6 +88,7 @@
#:use-module (gnu packages perl-compression)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
#:use-module (gnu packages rdf)
#:use-module (gnu packages scanner)
#:use-module (gnu packages tls)
@ -147,6 +149,7 @@ Plain Text, Gnumeric XML, Generic XML. It also includes low-level parsers for
CSV, CSS and XML.")
(license license:mpl2.0)))
;; TODO: Unoconv is deprecated in favor of github.com/unoconv/unoserver
(define-public unoconv
(package
(name "unoconv")
@ -157,38 +160,45 @@ CSV, CSS and XML.")
(uri (pypi-uri "unoconv" version))
(sha256
(base32 "0cb0bvyxib3xrj0jdgizhp6p057lr8kqnd3n921rin37ivcvz3ih"))))
(build-system python-build-system)
(build-system pyproject-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'stop-hash-sniffing
;; Fixes <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39647#11>.
;; Submitted upsteam: <https://github.com/unoconv/unoconv/pull/531>.
(lambda _
(substitute* "unoconv"
(("sys.argv\\[0\\]\\.split\\('2'\\)")
"os.path.basename(sys.argv[0]).split('2')"))
#t))
(add-after 'unpack 'patch-find_offices
;; find_offices is a convoluted cross-platform treasure hunt.
;; Keep things simple and return the correct paths immediately.
(lambda* (#:key inputs #:allow-other-keys)
(let* ((libreoffice (assoc-ref inputs "libreoffice")))
(substitute* "unoconv"
(("def find_offices\\(\\):" match)
(string-append
match "\n"
" return [Office("
"'" libreoffice "/lib/libreoffice', "
"'" libreoffice "/lib/libreoffice/program', "
"'" libreoffice "/lib/libreoffice/program', "
"'" libreoffice "/lib/libreoffice/program/pyuno.so', "
"'" libreoffice "/bin/soffice', "
"sys.executable, "
"None)]\n")))
#t))))))
(inputs
(list libreoffice))
(list
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'stop-hash-sniffing
;; Fixes <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39647#11>.
;; Submitted upsteam: <https://github.com/unoconv/unoconv/pull/531>.
(lambda _
(substitute* "unoconv"
(("sys.argv\\[0\\]\\.split\\('2'\\)")
"os.path.basename(sys.argv[0]).split('2')"))))
(add-after 'unpack 'patch-find_offices
;; find_offices is a convoluted cross-platform treasure hunt.
;; Keep things simple and return the correct paths immediately.
(lambda* (#:key inputs #:allow-other-keys)
(let* ((libreoffice (assoc-ref inputs "libreoffice")))
(substitute* "unoconv"
(("def find_offices\\(\\):" match)
(string-append
match "\n"
" return [Office("
"'" libreoffice "/lib/libreoffice', "
"'" libreoffice "/lib/libreoffice/program', "
"'" libreoffice "/lib/libreoffice/program', "
"'" libreoffice "/lib/libreoffice/program/pyuno.so', "
"'" libreoffice "/bin/soffice', "
"sys.executable, "
"None)]\n"))))))
(replace 'check
(lambda* (#:key inputs tests? test-flags #:allow-other-keys)
(setenv "HOME" (getcwd))
(let ((python (search-input-file inputs "bin/python")))
(when tests?
(with-directory-excursion "tests"
(invoke "make" "all"
(string-append "python=" python))))))))))
(native-inputs (list gnu-make python-setuptools))
(inputs (list libreoffice))
(home-page "http://dag.wiee.rs/home-made/unoconv/")
(synopsis "Convert between any document format supported by LibreOffice")
(description