gnu: protobuf: Update to 3.17.3.
[jackhill/guix/guix.git] / gnu / packages / protobuf.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016 Daniel Pimentel <d4n1@d4n1.org>
4 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
9 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages protobuf)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system cmake)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system python)
33 #:use-module (guix build-system emacs)
34 #:use-module (guix build-system ruby)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix utils)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages libevent)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages python-build)
44 #:use-module (gnu packages python-check)
45 #:use-module (gnu packages python-xyz)
46 #:use-module (gnu packages ruby))
47
48 (define-public fstrm
49 (package
50 (name "fstrm")
51 (version "0.3.2")
52 (source
53 (origin
54 (method url-fetch)
55 (uri (string-append "https://dl.farsightsecurity.com/dist/" name "/"
56 name "-" version ".tar.gz"))
57 (sha256
58 (base32
59 "1i9y8a1712aj80p5a1kcp378bnjrg3s2127q7304hklhmjcrjl1d"))))
60 (build-system gnu-build-system)
61 (native-inputs
62 `(("pkg-config" ,pkg-config)))
63 (inputs
64 `(("libevent" ,libevent)))
65 (home-page "https://github.com/farsightsec/fstrm")
66 (synopsis "Implementation of the Frame Streams data transport protocol")
67 (description
68 "fstrm is an optimised implementation of Frame Streams as a C library and
69 several tools built on top of it.
70
71 @dfn{Frame Streams} is a light-weight, binary-clean protocol that allows for
72 the transport of arbitrarily-encoded data payload sequences with minimal
73 framing overhead---just four bytes per data frame. It does not specify an
74 encoding format for these data frames and can be used with any data
75 serialisation format that produces byte sequences, such as Protocol Buffers,
76 XML, JSON, MessagePack, YAML, etc.
77
78 Frame Streams can be used either as a streaming transport over a reliable byte
79 stream socket (TCP sockets, TLS connections, @code{AF_UNIX} sockets, etc.) for
80 data in motion, or as a file format for data at rest.")
81 (license (list license:asl2.0
82 (license:non-copyleft #f "See libmy/argv*")))))
83
84 (define-public protobuf
85 (package
86 (name "protobuf")
87 (version "3.17.3")
88 (source (origin
89 (method url-fetch)
90 (uri (string-append "https://github.com/google/protobuf/releases/"
91 "download/v" version "/protobuf-cpp-"
92 version ".tar.gz"))
93 (sha256
94 (base32
95 "1jzqrklhj9grs6xbddyb5dyxfbgbgbyhl5zig8ml50wb22gwkkji"))))
96 (build-system gnu-build-system)
97 (inputs `(("zlib" ,zlib)))
98 (outputs (list "out"
99 "static")) ; ~12 MiB of .a files
100 (arguments
101 `(#:phases
102 (modify-phases %standard-phases
103 (add-after 'unpack 'disable-broken-tests
104 ;; The following tests fail on 32 bit architectures such as
105 ;; i686-linux.
106 (lambda _
107 (let-syntax ((disable-tests
108 (syntax-rules ()
109 ((_ file test ...)
110 (substitute* file
111 ((test name)
112 (string-append "DISABLED_" name)) ...)))))
113 ;; See: https://github.com/protocolbuffers/protobuf/issues/8460.
114 (disable-tests "src/google/protobuf/any_test.cc"
115 "TestPackFromSerializationExceedsSizeLimit")
116 ;; See: https://github.com/protocolbuffers/protobuf/issues/8459.
117 (disable-tests "src/google/protobuf/arena_unittest.cc"
118 "SpaceAllocated_and_Used"
119 "BlockSizeSmallerThanAllocation")
120 ;; See: https://github.com/protocolbuffers/protobuf/issues/8082.
121 (disable-tests "src/google/protobuf/io/zero_copy_stream_unittest.cc"
122 "LargeOutput"))))
123 (add-after 'install 'move-static-libraries
124 (lambda* (#:key outputs #:allow-other-keys)
125 ;; Move static libraries to the "static" output.
126 (let* ((out (assoc-ref outputs "out"))
127 (lib (string-append out "/lib"))
128 (static (assoc-ref outputs "static"))
129 (slib (string-append static "/lib")))
130 (mkdir-p slib)
131 (for-each (lambda (file)
132 (install-file file slib)
133 (delete-file file))
134 (find-files lib "\\.a$"))))))))
135 (home-page "https://github.com/google/protobuf")
136 (synopsis "Data encoding for remote procedure calls (RPCs)")
137 (description
138 "Protocol Buffers are a way of encoding structured data in an efficient
139 yet extensible format. Google uses Protocol Buffers for almost all of its
140 internal RPC protocols and file formats.")
141 (license license:bsd-3)))
142
143 ;; Tensorflow requires version 3.6 specifically.
144 (define-public protobuf-3.6
145 (package
146 (inherit protobuf)
147 (version "3.6.1")
148 (source (origin
149 (method url-fetch)
150 (uri (string-append "https://github.com/google/protobuf/releases/"
151 "download/v" version "/protobuf-cpp-"
152 version ".tar.gz"))
153 (sha256
154 (base32
155 "0a955bz59ihrb5wg7dwi12xajdi5pmz4bl0g147rbdwv393jwwxk"))))))
156
157 ;; The 3.5 series are the last versions that do not require C++ 11.
158 (define-public protobuf-3.5
159 (package
160 (inherit protobuf)
161 (version "3.5.1")
162 (source (origin
163 (method url-fetch)
164 (uri (string-append "https://github.com/google/protobuf/releases/"
165 "download/v" version "/protobuf-cpp-"
166 version ".tar.gz"))
167 (sha256
168 (base32
169 "14j0427ykjzrd9a66c2mpk0sjcccjlsx6q8ww6hzwb6sha3vm3f2"))))))
170
171 ;; XXX Remove this old version when no other packages depend on it.
172 (define-public protobuf-2
173 (package (inherit protobuf)
174 (version "2.6.1")
175 (source (origin
176 (method url-fetch)
177 (uri (string-append "https://github.com/google/protobuf/releases/"
178 "download/v" version "/protobuf-"
179 version ".tar.bz2"))
180 (sha256
181 (base32
182 "040rcs9fpv4bslhiy43v7dcrzakz4vwwpyqg4jp8bn24sl95ci7f"))))))
183
184 (define-public protobuf-c
185 (package
186 (name "protobuf-c")
187 (version "1.3.3")
188 (source (origin
189 (method url-fetch)
190 (uri (string-append "https://github.com/protobuf-c/protobuf-c/"
191 "releases/download/v" version
192 "/protobuf-c-" version ".tar.gz"))
193 (sha256
194 (base32
195 "0y3yaanq97si7iyld06p8w20m0shpj7sf4xwzbhhvijhxw36d592"))))
196 (build-system gnu-build-system)
197 (inputs `(("protobuf" ,protobuf)))
198 (native-inputs `(("pkg-config" ,pkg-config)))
199 (home-page "https://github.com/protobuf-c/protobuf-c")
200 (synopsis "Protocol Buffers implementation in C")
201 (description
202 "This is protobuf-c, a C implementation of the Google Protocol Buffers
203 data serialization format. It includes @code{libprotobuf-c}, a pure C library
204 that implements protobuf encoding and decoding, and @code{protoc-c}, a code
205 generator that converts Protocol Buffer @code{.proto} files to C descriptor
206 code.")
207 (license license:bsd-2)))
208
209 (define-public protozero
210 (package
211 (name "protozero")
212 (version "1.6.8")
213 (source
214 (origin
215 (method git-fetch)
216 (uri (git-reference
217 (url "https://github.com/mapbox/protozero")
218 (commit (string-append "v" version))))
219 (file-name (git-file-name name version))
220 (sha256
221 (base32 "1hfijpfylf1c71wa3mk70gjc88b6k1q7cxb87cwqdflw5q2x8ma6"))))
222 (build-system cmake-build-system)
223 (home-page "https://github.com/mapbox/protozero")
224 (synopsis "Minimalistic protocol buffer decoder and encoder in C++")
225 (description "Protozero is a minimalistic protocol buffer decoder and
226 encoder in C++. The developer using protozero has to manually translate the
227 @file{.proto} description into code.")
228 (license (list
229 license:asl2.0 ; for folly
230 license:bsd-2))))
231
232 (define-public python-protobuf
233 (package
234 (name "python-protobuf")
235 (version "3.12.4")
236 (source
237 (origin
238 (method url-fetch)
239 (uri (pypi-uri "protobuf" version))
240 (sha256
241 (base32
242 "0mj6z58aiw532s1mq48m9xdrm3gdyp2vv9cdinfb5wmnfpm5m7n9"))))
243 (build-system python-build-system)
244 (native-inputs
245 `(("python-wheel" ,python-wheel)))
246 (propagated-inputs
247 `(("python-six" ,python-six)))
248 (home-page "https://github.com/google/protobuf")
249 (synopsis "Protocol buffers is a data interchange format")
250 (description
251 "Protocol buffers are a language-neutral, platform-neutral extensible
252 mechanism for serializing structured data.")
253 (license license:bsd-3)))
254
255 (define-public python-pure-protobuf
256 (package
257 (name "python-pure-protobuf")
258 (version "2.0.1")
259 (source
260 (origin
261 ;; The PyPI tarball is broken: it has no tests.
262 (method git-fetch)
263 (uri (git-reference
264 (url "https://github.com/eigenein/protobuf")
265 (commit version)))
266 (file-name (git-file-name name version))
267 (sha256
268 (base32 "15dp5pvazd0jx4wzzh79080ah7hkpd3axh40al9vhzs2hf3v90hx"))))
269 (build-system python-build-system)
270 (native-inputs
271 `(("python-flake8" ,python-flake8)
272 ("python-pytest" ,python-pytest)
273 ("python-pytest-cov" ,python-pytest-cov)
274 ("python-isort" ,python-isort)))
275 (arguments
276 `(#:phases
277 (modify-phases %standard-phases
278 (add-before 'check 'setup-test-env
279 (lambda* (#:key outputs #:allow-other-keys)
280 (let* ((out (assoc-ref outputs "out"))
281 (py3sitedir
282 (string-append out "/lib/python"
283 ,(version-major+minor
284 (package-version python))
285 "/site-packages")))
286 (setenv "PYTHONPATH"
287 (string-append py3sitedir ":"
288 (getenv "PYTHONPATH"))))
289 #t))
290 (replace 'check
291 (lambda _
292 (invoke "pytest" "--cov-report" "term-missing" "--cov"
293 "pure_protobuf")
294 (invoke "flake8" "pure_protobuf" "tests"
295 "--ignore=F541")
296 (invoke "isort" "-rc" "-c" "pure_protobuf" "tests")
297 #t)))))
298 (home-page "https://pypi.org/project/pure-protobuf/")
299 (synopsis "Protobuf implementation using dataclasses")
300 (description
301 "@code{python-pure-protobuf} takes advantage of the standard
302 dataclasses module to define message types. Protocol buffers are a
303 language-neutral, platform-neutral extensible mechanism for serializing
304 structured data.")
305 (license license:expat)))
306
307 (define-public python2-protobuf
308 (package-with-python2 python-protobuf))
309
310 ;; For tensorflow.
311 (define-public python-protobuf-3.6
312 (package
313 (inherit python-protobuf)
314 (name "python-protobuf")
315 (version (package-version protobuf-3.6) )
316 (source
317 (origin
318 (method url-fetch)
319 (uri (pypi-uri "protobuf" version))
320 (sha256
321 (base32
322 "04bqb12smlckzmgkj6vgmpbr3cby0n6726cmz33bqr7kn1vb728l"))))))
323
324 (define-public emacs-protobuf-mode
325 (package
326 (name "emacs-protobuf-mode")
327 (version (package-version protobuf))
328 (source (package-source protobuf))
329 (build-system emacs-build-system)
330 (arguments
331 `(#:phases
332 (modify-phases %standard-phases
333 (add-before 'expand-load-path 'change-working-directory
334 (lambda _ (chdir "editors") #t)))))
335 (home-page "https://github.com/protocolbuffers/protobuf")
336 (synopsis "Protocol buffers major mode for Emacs")
337 (description
338 "This package provides an Emacs major mode for editing Protocol Buffer
339 source files.")
340 (license license:bsd-3)))
341
342 (define-public ruby-protobuf
343 (package
344 (name "ruby-protobuf")
345 (version "3.10.3")
346 (source (origin
347 (method git-fetch)
348 (uri (git-reference
349 (url "https://github.com/ruby-protobuf/protobuf")
350 (commit (string-append "v" version))))
351 (file-name (git-file-name name version))
352 (sha256
353 (base32
354 "1yzz7jgpp6qip5d6qhzbkf5gqaydfk3z3c1ngccwzp6w6wa75g8a"))))
355 (build-system ruby-build-system)
356 (arguments
357 `(#:phases
358 (modify-phases %standard-phases
359 (add-after 'unpack 'do-not-use-bundler-for-tests
360 (lambda _
361 (substitute* "spec/spec_helper.rb"
362 (("Bundler\\.setup.*") ""))
363 #t))
364 (add-after 'unpack 'relax-version-requirements
365 (lambda _
366 (substitute* ((@@ (guix build ruby-build-system) first-gemspec))
367 (("'rake',.*")
368 "'rake'\n")
369 (("\"rubocop\",.*")
370 "'rubocop'\n")
371 (("\"parser\",.*")
372 "'parser'\n"))
373 #t))
374 (add-after 'unpack 'patch-protoc
375 (lambda* (#:key inputs #:allow-other-keys)
376 (let ((protoc (assoc-ref inputs "protobuf")))
377 (substitute* "lib/protobuf/tasks/compile.rake"
378 (("\"protoc\"")
379 (string-append "\"" protoc "/bin/protoc" "\"")))
380 #t)))
381 (add-after 'unpack 'skip-failing-test
382 ;; See: https://github.com/ruby-protobuf/protobuf/issues/419
383 (lambda _
384 (substitute* "spec/lib/protobuf/rpc/connectors/ping_spec.rb"
385 (("expect\\(::IO\\)\\.to receive\\(:select\\).*" all)
386 (string-append " pending\n" all)))
387 #t))
388 (add-after 'replace-git-ls-files 'replace-more-git-ls-files
389 (lambda _
390 (substitute* ((@@ (guix build ruby-build-system) first-gemspec))
391 (("`git ls-files -- \\{test,spec,features\\}/*`")
392 "`find test spec features -type f | sort`")
393 (("`git ls-files -- bin/*`")
394 "`find bin -type f | sort`"))
395 #t))
396 (replace 'check
397 (lambda _
398 (invoke "rspec"))))))
399 (native-inputs
400 `(("ruby-benchmark-ips" ,ruby-benchmark-ips)
401 ("ruby-ffi-rzmq" ,ruby-ffi-rzmq)
402 ("ruby-parser" ,ruby-parser)
403 ("ruby-pry-byebug" ,ruby-pry-byebug)
404 ("ruby-pry-stack-explorer" ,ruby-pry-stack-explorer)
405 ("ruby-rake" ,ruby-rake)
406 ("ruby-rspec" ,ruby-rspec)
407 ("ruby-rubocop" ,ruby-rubocop)
408 ("ruby-ruby-prof" ,ruby-ruby-prof)
409 ("ruby-simplecov" ,ruby-simplecov)
410 ("ruby-timecop" ,ruby-timecop)
411 ("ruby-varint" ,ruby-varint)
412 ("ruby-yard" ,ruby-yard)))
413 (inputs
414 `(("protobuf" ,protobuf)))
415 (propagated-inputs
416 `(("ruby-activesupport" ,ruby-activesupport)
417 ("ruby-middleware" ,ruby-middleware)
418 ("ruby-thor" ,ruby-thor)
419 ("ruby-thread-safe" ,ruby-thread-safe)))
420 (home-page "https://github.com/ruby-protobuf/protobuf")
421 (synopsis "Implementation of Google's Protocol Buffers in Ruby")
422 (description "Protobuf is an implementation of Google's Protocol Buffers
423 in pure Ruby.")
424 (license license:expat)))
425
426 ;;; This is a modified ruby-protobuf package used by ruby-cucumber-messages
427 ;;; until https://github.com/ruby-protobuf/protobuf/pull/411 and
428 ;;; https://github.com/ruby-protobuf/protobuf/pull/415 are merged upstream.
429 (define-public ruby-protobuf-cucumber
430 (hidden-package
431 (package
432 (inherit ruby-protobuf)
433 (name "ruby-protobuf-cucumber")
434 (version "3.10.8")
435 (source
436 (origin
437 (method url-fetch)
438 (uri (rubygems-uri "protobuf-cucumber" version))
439 (sha256
440 (base32
441 "1rd6naabhpfb1i5dr6fp5mqwaawsx0mqm73h5ycwkgbm1n2si872")))))))