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