gnu: opencc: Update to 1.1.1.

* gnu/packages/textutils.scm(opencc): Update to 1.1.1
[arguments]<#:out-of-source?>: Build in source tree.
<#:parallel-build?>: Disable.
<#:phases>: In "patch-3rd-party-references", fix the version of dependency.
Add phases "patch-python-binding-installation", "install-python-binding"
and "enable-bytecode-determinism".
[native-inputs]: Add python-setuptools and python-wheel.

Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
This commit is contained in:
Zhu Zihao 2021-02-15 00:23:37 +08:00 committed by Nicolas Goaziou
parent 5e753287c8
commit 2ee7524c76
No known key found for this signature in database
GPG key ID: DA00B4F048E92F2D

View file

@ -60,6 +60,7 @@ (define-module (gnu packages textutils)
#:use-module (gnu packages perl) #:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config) #:use-module (gnu packages pkg-config)
#:use-module (gnu packages python) #:use-module (gnu packages python)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-xyz) #:use-module (gnu packages python-xyz)
#:use-module (gnu packages readline) #:use-module (gnu packages readline)
#:use-module (gnu packages slang) #:use-module (gnu packages slang)
@ -1051,7 +1052,7 @@ (define-public odt2txt
(define-public opencc (define-public opencc
(package (package
(name "opencc") (name "opencc")
(version "1.0.5") (version "1.1.1")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -1061,26 +1062,69 @@ (define-public opencc
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"1pv5md225qwhbn8ql932zdg6gh1qlx3paiajaks8gfsa07yzvhr4")) "07y0pvxjlmpcnym229j87qcfwnfm7vi10dad0a20xy6as55a9j3d"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
'(begin '(begin
;; TODO: Unbundle tclap, darts-clone, gtest ;; TODO: Unbundle tclap, darts-clone, gtest
(delete-file-recursively "deps/rapidjson-0.11") #t)))) (delete-file-recursively "deps/rapidjson-1.1.0") #t))))
(build-system cmake-build-system) (build-system cmake-build-system)
(arguments (arguments
'(#:phases ;; Required to locate the install script properly.
`(#:out-of-source? #f
#:parallel-build? #f ;occasionally failed.
#:imported-modules
(,@%cmake-build-system-modules
(guix build python-build-system))
#:modules ((guix build cmake-build-system)
((guix build python-build-system) #:prefix python:)
(guix build utils))
#:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'unpack 'prevent-rebuild-during-installation
(lambda _
(substitute* "python/setup.py"
(("'build_py': BuildPyCommand,") ""))
#t))
(add-after 'unpack 'patch-3rd-party-references (add-after 'unpack 'patch-3rd-party-references
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((rapidjson (assoc-ref inputs "rapidjson"))) (let ((rapidjson (assoc-ref inputs "rapidjson")))
(substitute* "src/CMakeLists.txt" (substitute* "src/CMakeLists.txt"
(("../deps/rapidjson-0.11") (("../deps/rapidjson-1.1.0")
(string-append rapidjson "/include/rapidjson"))) (string-append rapidjson "/include/rapidjson")))
#t)))))) #t)))
(add-before 'configure 'patch-python-binding-installation
(lambda* (#:key outputs inputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(substitute* "python/opencc/__init__.py"
(("(_libopenccfile =).*$" _ prefix)
(format #f "~a os.path.join('~a/lib', _libopenccfilename)~%"
prefix out))
(("(_opencc_share_dir =).*$" _ prefix)
(format #f "~a '~a/share/opencc'~%" prefix out))))
#t))
(add-after 'install 'install-python-binding
(lambda* (#:key outputs inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(dist (string-append
out "/lib/python"
,(version-major+minor (package-version python))
"/site-packages")))
(chdir "python")
(mkdir-p dist)
(setenv "PYTHONPATH"
(string-append dist ":" (getenv "PYTHONPATH")))
(invoke "python" "setup.py" "install"
"--root=/" "--single-version-externally-managed"
(string-append "--prefix=" out))
#t)))
(add-before 'install-python-binding 'enable-bytecode-determinism
(assoc-ref python:%standard-phases 'enable-bytecode-determinism)))))
(native-inputs (native-inputs
`(("python" ,python-wrapper) `(("python" ,python-wrapper)
("rapidjson" ,rapidjson))) ("rapidjson" ,rapidjson)
("python-setuptools" ,python-setuptools)
("python-wheel" ,python-wheel)))
(home-page "https://github.com/BYVoid/OpenCC") (home-page "https://github.com/BYVoid/OpenCC")
(synopsis "Convert between Traditional Chinese and Simplified Chinese") (synopsis "Convert between Traditional Chinese and Simplified Chinese")
(description "Open Chinese Convert (OpenCC) converts between Traditional (description "Open Chinese Convert (OpenCC) converts between Traditional