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