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