gnu: grpc: Update to 1.33.2.
[jackhill/guix/guix.git] / gnu / packages / rpc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages rpc)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix git-download)
26 #:use-module (guix download)
27 #:use-module (guix utils)
28 #:use-module (guix build-system cmake)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system python)
31 #:use-module (gnu packages adns)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages boost)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cpp)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages protobuf)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages python-xyz)
42 #:use-module (gnu packages regex)
43 #:use-module (gnu packages tls))
44
45 (define-public grpc
46 (package
47 (name "grpc")
48 (version "1.33.2")
49 (outputs '("out" "static"))
50 (source (origin
51 (method git-fetch)
52 (uri (git-reference
53 (url "https://github.com/grpc/grpc")
54 (commit (string-append "v" version))))
55 (file-name (git-file-name name version))
56 (sha256
57 (base32
58 "09xd9pkyp10gh051kf8kwxn4myw42zv8kngr9z8wpm6mjy0j4ylw"))))
59 (build-system cmake-build-system)
60 (arguments
61 `(#:tests? #f ; no test target
62 #:configure-flags
63 (list "-DgRPC_ZLIB_PROVIDER=package"
64 "-DgRPC_ABSL_PROVIDER=package"
65 "-DgRPC_CARES_PROVIDER=package"
66 "-DgRPC_SSL_PROVIDER=package"
67 "-DgRPC_PROTOBUF_PROVIDER=package"
68 "-DgRPC_RE2_PROVIDER=package"
69 (string-append "-DCMAKE_INSTALL_PREFIX="
70 (assoc-ref %outputs "out"))
71 "-DCMAKE_INSTALL_LIBDIR=lib"
72 (string-append "-DCMAKE_INSTALL_RPATH="
73 (assoc-ref %outputs "out") "/lib")
74 "-DCMAKE_VERBOSE_MAKEFILE=ON")
75 #:phases
76 (modify-phases %standard-phases
77 (add-before 'configure 'configure-shared
78 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
79 (mkdir "../build-shared")
80 (with-directory-excursion "../build-shared"
81 (apply invoke
82 "cmake" "../source"
83 "-DBUILD_SHARED_LIBS=ON"
84 configure-flags)
85 (apply invoke "make"
86 `("-j" ,(number->string (parallel-job-count)))))))
87 (add-after 'install 'install-shared-libraries
88 (lambda _
89 (with-directory-excursion "../build-shared"
90 (invoke "make" "install"))))
91 (add-before 'strip 'move-static-libs
92 (lambda* (#:key outputs #:allow-other-keys)
93 (let ((out (assoc-ref outputs "out"))
94 (static (assoc-ref outputs "static")))
95 (mkdir-p (string-append static "/lib"))
96 (with-directory-excursion
97 (string-append out "/lib")
98 (for-each
99 (lambda (file)
100 (rename-file file
101 (string-append static "/lib/" file)))
102 (find-files "." "\\.a$"))))
103 #t)))))
104 (inputs
105 `(("abseil-cpp" ,abseil-cpp)
106 ("c-ares" ,c-ares/cmake)
107 ("openssl" ,openssl)
108 ("re2" ,re2)
109 ("zlib" ,zlib)))
110 (native-inputs
111 `(("pkg-config" ,pkg-config)
112 ("protobuf" ,protobuf)
113 ("python" ,python-wrapper)))
114 (home-page "https://grpc.io")
115 (synopsis "High performance universal RPC framework")
116 (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
117 (RPC) framework that can run in any environment. It can efficiently connect
118 services in and across data centers with pluggable support for load balancing,
119 tracing, health checking and authentication. It is also applicable in last
120 mile of distributed computing to connect devices, mobile applications and
121 browsers to backend services.")
122 (license license:asl2.0)))
123
124 ;; Some packages require this older version.
125 (define-public grpc-1.16.1
126 (package
127 (inherit grpc)
128 (version "1.16.1")
129 (source (origin
130 (method git-fetch)
131 (uri (git-reference
132 (url "https://github.com/grpc/grpc")
133 (commit (string-append "v" version))))
134 (file-name (git-file-name "grpc" version))
135 (sha256
136 (base32
137 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
138 (arguments
139 (substitute-keyword-arguments (package-arguments grpc)
140 ((#:phases phases)
141 `(modify-phases ,phases
142 ;; Note: This would be nicer as a snippet, but that creates a tarball
143 ;; instead of a checkout and breaks assumptions made by the builder.
144 (add-after 'unpack 'rename-gettid
145 (lambda _
146 ;; Rename custom gettid() syscall wrapper to avoid conflict
147 ;; with gettid() from glibc 2.30.
148 (substitute* '("src/core/lib/gpr/log_linux.cc"
149 "src/core/lib/gpr/log_posix.cc"
150 "src/core/lib/iomgr/ev_epollex_linux.cc")
151 (("gettid\\(")
152 "sys_gettid("))
153 #t))))))))
154
155 (define-public python-grpcio
156 (package
157 (name "python-grpcio")
158 (version "1.27.2")
159 (source
160 (origin
161 (method url-fetch)
162 (uri (pypi-uri "grpcio" version))
163 (sha256
164 (base32
165 "0zl89jwcff9hkd8mi4yf3qbhns9vbv1s4x4vahm5mkpr7jwk5ras"))
166 (modules '((guix build utils) (ice-9 ftw)))
167 (snippet
168 '(begin
169 (with-directory-excursion "third_party"
170 ;; Delete the bundled source code of libraries that are possible
171 ;; to provide as inputs.
172 (for-each delete-file-recursively
173 (scandir "."
174 (lambda (file)
175 (not (member file
176 '("." ".."
177 "abseil-cpp"
178 "address_sorting"
179 "upb")))))))
180 #t))))
181 (build-system python-build-system)
182 (arguments
183 '(#:phases (modify-phases %standard-phases
184 (add-before 'build 'use-system-libraries
185 (lambda _
186 (setenv "GRPC_PYTHON_BUILD_SYSTEM_CARES" "1")
187 (setenv "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL" "1")
188 (setenv "GRPC_PYTHON_BUILD_SYSTEM_ZLIB" "1")
189 #t))
190 (add-before 'build 'configure-compiler
191 (lambda _
192 (substitute* '("setup.py" "src/python/grpcio/commands.py")
193 (("'cc'") "'gcc'"))
194 #t)))))
195 (inputs
196 `(("c-ares" ,c-ares)
197 ("openssl" ,openssl)
198 ("zlib" ,zlib)))
199 (propagated-inputs
200 `(("python-six" ,python-six)))
201 (home-page "https://grpc.io")
202 (synopsis "HTTP/2-based RPC framework")
203 (description "This package provides a Python library for communicating
204 with the HTTP/2-based RPC framework gRPC.")
205 (license license:asl2.0)))
206
207 (define-public apache-thrift
208 (package
209 (name "apache-thrift")
210 (version "0.13.0")
211 (source
212 (origin
213 (method git-fetch)
214 (uri (git-reference
215 (url "https://github.com/apache/thrift")
216 (commit (string-append "v" version))))
217 (file-name (git-file-name name version))
218 (sha256
219 (base32
220 "17ckl7p7s3ga33yrjisilsimp80ansqxl54wvpkv0j7vx2zvc13y"))))
221 (build-system gnu-build-system)
222 (arguments
223 '(#:tests? #f
224 #:configure-flags
225 (list (string-append "--with-boost="
226 (assoc-ref %build-inputs "boost")))))
227 (native-inputs
228 `(("autoconf" ,autoconf)
229 ("automake" ,automake)
230 ("libtool" ,libtool)
231 ("pkg-config" ,pkg-config)
232 ("flex" ,flex)
233 ("bison" ,bison)))
234 (inputs
235 `(("boost" ,boost)
236 ("libressl" ,libressl)))
237 (outputs '("out" "lib" "include"))
238 (home-page "https://thrift.apache.org/")
239 (synopsis
240 "Lightweight, language-independent software stack for point-to-point
241 RPC")
242 (description
243 "Thrift provides clean abstractions and implementations for data
244 transport, data serialization, and application level processing. The code
245 generation system takes a simple definition language as input and generates
246 code across programming languages that uses the abstracted stack to build
247 interoperable RPC clients and servers.")
248 (license license:asl2.0)))