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