~ruther/guix-local

d3600a04c934f8a11014f1ef0082c58cb9a51634 — Nicolas Graves 3 months ago 56bd65a
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>
1 files changed, 41 insertions(+), 31 deletions(-)

M gnu/packages/libreoffice.scm
M gnu/packages/libreoffice.scm => gnu/packages/libreoffice.scm +41 -31
@@ 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