diff options
Diffstat (limited to 'gnu/packages/protobuf.scm')
-rw-r--r-- | gnu/packages/protobuf.scm | 182 |
1 files changed, 116 insertions, 66 deletions
diff --git a/gnu/packages/protobuf.scm b/gnu/packages/protobuf.scm index 765836cf65..51e983cd00 100644 --- a/gnu/packages/protobuf.scm +++ b/gnu/packages/protobuf.scm @@ -4,7 +4,7 @@ ;;; Copyright © 2016 Leo Famulari <leo@famulari.name> ;;; Copyright © 2017-2019, 2022-2025 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> -;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim@guixotic.coop> ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net> ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org> ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net> @@ -42,6 +42,7 @@ #:use-module (gnu packages build-tools) #:use-module (gnu packages compression) #:use-module (gnu packages check) + #:use-module (gnu packages cpp) #:use-module (gnu packages gcc) #:use-module (gnu packages libevent) #:use-module (gnu packages pkg-config) @@ -51,8 +52,10 @@ #:use-module (gnu packages python-xyz) #:use-module (gnu packages rpc) #:use-module (gnu packages rails) + #:use-module (gnu packages ruby) #:use-module (gnu packages ruby-check) #:use-module (gnu packages ruby-xyz) + #:use-module (gnu packages serialization) #:use-module (srfi srfi-1)) (define-public fstrm @@ -93,6 +96,109 @@ data in motion, or as a file format for data at rest.") (license (list license:expat ; the combined work license:hpnd)))) ; libmy/argv* +;; Onnx requires version >=4.25.1 specifically. +(define-public protobuf-6 + (package + (name "protobuf") + (version "6.31.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/protocolbuffers/protobuf/") + (commit (string-append "v" version)))) + (modules '((guix build utils) + (ice-9 ftw) + (srfi srfi-26))) + (snippet + #~(begin + ;; XXX: 'delete-all-but' is copied from the turbovnc package. + (define (delete-all-but directory . preserve) + (define (directory? x) + (and=> (stat x #f) + (compose (cut eq? 'directory <>) stat:type))) + (with-directory-excursion directory + (let* ((pred + (negate (cut member <> (append '("." "..") preserve)))) + (items (scandir "." pred))) + (for-each delete-file-recursively items)))) + ;; "utf8_range" development now takes place in main protobuf + ;; repository. + (delete-all-but "third_party" "utf8_range"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1rdxm75bqwjj4qd3hz4vlydra6bw5dq391kwln2q0pjfx9gbrjhk")))) + (outputs (list "out" "static")) + (build-system cmake-build-system) + (arguments + (list + #:configure-flags + #~(list "-DBUILD_SHARED_LIBS=ON") + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'disable-broken-tests + ;; The following tests used to fail on 32 bit architectures + ;; such as i686-linux. + (lambda _ + (let-syntax ((disable-tests + (syntax-rules () + ((_ file test ...) + (substitute* file + ((test name) + (string-append "DISABLED_" name)) ...))))) + ;; https://github.com/protocolbuffers/protobuf/issues/8460. + (disable-tests + "src/google/protobuf/any_test.cc" + "TestPackFromSerializationExceedsSizeLimit") + ;; https://github.com/protocolbuffers/protobuf/issues/8459. + (disable-tests + "src/google/protobuf/arena_unittest.cc" + "SpaceAllocated_and_Used" + "BlockSizeSmallerThanAllocation") + ;; https://github.com/protocolbuffers/protobuf/issues/8082. + (disable-tests + "src/google/protobuf/io/zero_copy_stream_unittest.cc" + "LargeOutput")))) + (add-after 'install 'move-static-libraries + (lambda* (#:key outputs #:allow-other-keys) + ;; Move static libraries to the "static" output. + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib")) + (static (assoc-ref outputs "static")) + (slib (string-append static "/lib"))) + (mkdir-p slib) + (for-each (lambda (file) + (install-file file slib) + (delete-file file)) + (find-files lib "\\.a$")))))))) + (native-inputs (list googletest python-minimal-wrapper ruby)) + (inputs (list abseil-cpp jsoncpp zlib)) + (home-page "https://protobuf.dev") + (synopsis "Data encoding for remote procedure calls (RPCs)") + (description + "Protocol Buffers are a way of encoding structured data in an efficient +yet extensible format. Google uses Protocol Buffers for almost all of its +internal RPC protocols and file formats.") + (license license:bsd-3))) + +(define-public python-protobuf-6 + (package + (inherit protobuf-6) + (name "python-protobuf") + (version "6.31.1") + (source + (origin + (method url-fetch) + (uri (pypi-uri "protobuf" version)) + (sha256 + (base32 + "16nakbb14jjzhgmrvpn0g7k0iasgl8p0xa3kvjj5gfghhb4w9jnq")))) + (outputs (list "out")) + (build-system pyproject-build-system) + (arguments (list #:tests? #f)) ;no tests provided for Python variant + (native-inputs (list python-setuptools python-wheel)) + (inputs (list protobuf-6)))) + (define-public protobuf (package (name "protobuf") @@ -219,20 +325,6 @@ internal RPC protocols and file formats.") #~(modify-phases #$phases (delete 'set-c++-standard))))))) -;; The 3.5 series are the last versions that do not require C++ 11. -(define-public protobuf-3.5 - (package - (inherit protobuf-3.6) - (version "3.5.1") - (source (origin - (method url-fetch) - (uri (string-append "https://github.com/google/protobuf/releases/" - "download/v" version "/protobuf-cpp-" - version ".tar.gz")) - (sha256 - (base32 - "14j0427ykjzrd9a66c2mpk0sjcccjlsx6q8ww6hzwb6sha3vm3f2")))))) - ;; XXX Remove this old version when no other packages depend on it. (define-public protobuf-2 (package (inherit protobuf) @@ -284,20 +376,6 @@ generator that converts Protocol Buffer @code{.proto} files to C descriptor code.") (license license:bsd-2))) -(define-public protobuf-c-for-aiscm - (package - (inherit protobuf-c) - (version "1.3.3") - (source (origin - (method url-fetch) - (uri (string-append "https://github.com/protobuf-c/protobuf-c/" - "releases/download/v" version - "/protobuf-c-" version ".tar.gz")) - (sha256 - (base32 - "0y3yaanq97si7iyld06p8w20m0shpj7sf4xwzbhhvijhxw36d592")))) - (inputs (list protobuf-3.6)))) - (define-public protozero (package (name "protozero") @@ -413,13 +491,18 @@ from protobuf specification files.") (package (inherit nanopb) (name "python-nanopb") - (build-system python-build-system) + (build-system pyproject-build-system) (arguments (list #:tests? #f ;no Python-specific tests #:phases #~(modify-phases %standard-phases - (replace 'build + (add-after 'unpack 'use-poetry-core + (lambda _ + ;; Patch to use the core poetry API. + (substitute* "extra/poetry/pyproject.toml" + (("poetry.masonry.api") "poetry.core.masonry.api")))) + (add-before 'build 'pre-build (lambda _ (copy-file "extra/poetry/pyproject.toml" "pyproject.toml") (delete-file "build.py") @@ -428,14 +511,8 @@ from protobuf specification files.") (copy-recursively "generator" "nanopb/generator") (invoke "touch" "nanopb/__init__.py" "nanopb/generator/__init__.py") - (invoke "make" "-C" "nanopb/generator/proto") - (invoke "python" "-m" "build" "--wheel" "--no-isolation" "."))) - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((whl (car (find-files "dist" "\\.whl$")))) - (invoke "pip" "--no-cache-dir" "--no-input" - "install" "--no-deps" "--prefix" #$output whl))))))) - (native-inputs (list poetry protobuf python-pypa-build)) + (invoke "make" "-C" "nanopb/generator/proto")))))) + (native-inputs (list python-poetry-core protobuf python-setuptools)) (propagated-inputs (list python-protobuf)) (synopsis "Small code-size Protocol Buffers implementation in Python"))) @@ -534,33 +611,6 @@ language-neutral, platform-neutral extensible mechanism for serializing structured data.") (license license:expat))) -;; For tensorflow. -(define-public python-protobuf-3.6 - (package - (inherit python-protobuf) - (name "python-protobuf") - (version (package-version protobuf-3.6) ) - (source - (origin - (method url-fetch) - (uri (pypi-uri "protobuf" version)) - (sha256 - (base32 - "04bqb12smlckzmgkj6vgmpbr3cby0n6726cmz33bqr7kn1vb728l")))) - (arguments - (list - #:phases - '(modify-phases %standard-phases - (add-after 'unpack 'compatibility - (lambda _ - (substitute* '("google/protobuf/internal/containers.py" - "google/protobuf/internal/well_known_types.py") - (("collections.Mutable") - "collections.abc.Mutable"))))))) - (inputs (list python-six)) - (native-inputs - (list python-setuptools-for-tensorflow)))) - (define-public python-proto-plus (package (name "python-proto-plus") |