Commit | Line | Data |
---|---|---|
c61557b1 MB |
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> | |
447fafe3 | 4 | ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com> |
c61557b1 MB |
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) | |
f2c7513d | 25 | #:use-module (guix download) |
8cc103cb | 26 | #:use-module (guix utils) |
c61557b1 | 27 | #:use-module (guix build-system cmake) |
f2c7513d | 28 | #:use-module (guix build-system python) |
c61557b1 MB |
29 | #:use-module (gnu packages adns) |
30 | #:use-module (gnu packages compression) | |
447fafe3 | 31 | #:use-module (gnu packages cpp) |
c61557b1 MB |
32 | #:use-module (gnu packages protobuf) |
33 | #:use-module (gnu packages python) | |
f2c7513d | 34 | #:use-module (gnu packages python-xyz) |
c61557b1 MB |
35 | #:use-module (gnu packages tls)) |
36 | ||
37 | (define-public grpc | |
38 | (package | |
39 | (name "grpc") | |
447fafe3 | 40 | (version "1.27.3") |
c61557b1 MB |
41 | (outputs '("out" "static")) |
42 | (source (origin | |
43 | (method git-fetch) | |
44 | (uri (git-reference | |
45 | (url "https://github.com/grpc/grpc.git") | |
46 | (commit (string-append "v" version)))) | |
47 | (file-name (git-file-name name version)) | |
48 | (sha256 | |
49 | (base32 | |
447fafe3 | 50 | "0czmbwnafc7jnrrq2fnac2av83vs2q7q0wy4k11w9zbpld7j5h6d")))) |
c61557b1 MB |
51 | (build-system cmake-build-system) |
52 | (arguments | |
53 | `(#:tests? #f ; no test target | |
54 | #:configure-flags | |
55 | (list "-DgRPC_ZLIB_PROVIDER=package" | |
447fafe3 | 56 | "-DgRPC_ABSL_PROVIDER=package" |
c61557b1 MB |
57 | "-DgRPC_CARES_PROVIDER=package" |
58 | "-DgRPC_SSL_PROVIDER=package" | |
59 | "-DgRPC_PROTOBUF_PROVIDER=package" | |
60 | (string-append "-DCMAKE_INSTALL_PREFIX=" | |
61 | (assoc-ref %outputs "out")) | |
62 | "-DCMAKE_INSTALL_LIBDIR=lib" | |
63 | (string-append "-DCMAKE_INSTALL_RPATH=" | |
64 | (assoc-ref %outputs "out") "/lib") | |
65 | "-DCMAKE_VERBOSE_MAKEFILE=ON") | |
66 | #:phases | |
67 | (modify-phases %standard-phases | |
68 | (add-before 'configure 'configure-shared | |
69 | (lambda* (#:key (configure-flags '()) #:allow-other-keys) | |
70 | (mkdir "../build-shared") | |
71 | (with-directory-excursion "../build-shared" | |
72 | (apply invoke | |
73 | "cmake" "../source" | |
74 | "-DBUILD_SHARED_LIBS=ON" | |
75 | configure-flags) | |
76 | (apply invoke "make" | |
77 | `("-j" ,(number->string (parallel-job-count))))))) | |
78 | (add-after 'install 'install-shared-libraries | |
79 | (lambda _ | |
80 | (with-directory-excursion "../build-shared" | |
81 | (invoke "make" "install")))) | |
82 | (add-before 'strip 'move-static-libs | |
83 | (lambda* (#:key outputs #:allow-other-keys) | |
84 | (let ((out (assoc-ref outputs "out")) | |
85 | (static (assoc-ref outputs "static"))) | |
86 | (mkdir-p (string-append static "/lib")) | |
87 | (with-directory-excursion | |
88 | (string-append out "/lib") | |
89 | (for-each | |
90 | (lambda (file) | |
91 | (rename-file file | |
92 | (string-append static "/lib/" file))) | |
93 | (find-files "." "\\.a$")))) | |
94 | #t))))) | |
95 | (inputs | |
447fafe3 MB |
96 | `(("abseil-cpp" ,abseil-cpp) |
97 | ("c-ares" ,c-ares/cmake) | |
c61557b1 MB |
98 | ("openssl" ,openssl) |
99 | ("zlib" ,zlib))) | |
100 | (native-inputs | |
101 | `(("protobuf" ,protobuf) | |
102 | ("python" ,python-wrapper))) | |
103 | (home-page "https://grpc.io") | |
104 | (synopsis "High performance universal RPC framework") | |
105 | (description "gRPC is a modern high performance @dfn{Remote Procedure Call} | |
106 | (RPC) framework that can run in any environment. It can efficiently connect | |
107 | services in and across data centers with pluggable support for load balancing, | |
108 | tracing, health checking and authentication. It is also applicable in last | |
109 | mile of distributed computing to connect devices, mobile applications and | |
110 | browsers to backend services.") | |
111 | (license license:asl2.0))) | |
f2c7513d | 112 | |
447fafe3 MB |
113 | ;; Some packages require this older version. |
114 | (define-public grpc-1.16.1 | |
115 | (package | |
116 | (inherit grpc) | |
117 | (version "1.16.1") | |
118 | (source (origin | |
119 | (method git-fetch) | |
120 | (uri (git-reference | |
121 | (url "https://github.com/grpc/grpc.git") | |
122 | (commit (string-append "v" version)))) | |
123 | (file-name (git-file-name "grpc" version)) | |
124 | (sha256 | |
125 | (base32 | |
8cc103cb MB |
126 | "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2")))) |
127 | (arguments | |
128 | (substitute-keyword-arguments (package-arguments grpc) | |
129 | ((#:phases phases) | |
130 | `(modify-phases ,phases | |
131 | ;; Note: This would be nicer as a snippet, but that creates a tarball | |
132 | ;; instead of a checkout and breaks assumptions made by the builder. | |
133 | (add-after 'unpack 'rename-gettid | |
134 | (lambda _ | |
135 | ;; Rename custom gettid() syscall wrapper to avoid conflict | |
136 | ;; with gettid() from glibc 2.30. | |
137 | (substitute* '("src/core/lib/gpr/log_linux.cc" | |
138 | "src/core/lib/gpr/log_posix.cc" | |
139 | "src/core/lib/iomgr/ev_epollex_linux.cc") | |
140 | (("gettid\\(") | |
141 | "sys_gettid(")) | |
142 | #t)))))))) | |
447fafe3 | 143 | |
f2c7513d MB |
144 | (define-public python-grpcio |
145 | (package | |
146 | (name "python-grpcio") | |
9dec9122 | 147 | (version "1.27.2") |
f2c7513d MB |
148 | (source |
149 | (origin | |
150 | (method url-fetch) | |
151 | (uri (pypi-uri "grpcio" version)) | |
152 | (sha256 | |
153 | (base32 | |
9dec9122 MB |
154 | "0zl89jwcff9hkd8mi4yf3qbhns9vbv1s4x4vahm5mkpr7jwk5ras")) |
155 | (modules '((guix build utils) (ice-9 ftw))) | |
156 | (snippet | |
157 | '(begin | |
158 | (with-directory-excursion "third_party" | |
159 | ;; Delete the bundled source code of libraries that are possible | |
160 | ;; to provide as inputs. | |
161 | (for-each delete-file-recursively | |
162 | (scandir "." | |
163 | (lambda (file) | |
164 | (not (member file | |
165 | '("." ".." | |
166 | "abseil-cpp" | |
167 | "address_sorting" | |
168 | "upb"))))))) | |
169 | #t)))) | |
f2c7513d | 170 | (build-system python-build-system) |
9dec9122 MB |
171 | (arguments |
172 | '(#:phases (modify-phases %standard-phases | |
173 | (add-before 'build 'use-system-libraries | |
174 | (lambda _ | |
175 | (setenv "GRPC_PYTHON_BUILD_SYSTEM_CARES" "1") | |
176 | (setenv "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL" "1") | |
177 | (setenv "GRPC_PYTHON_BUILD_SYSTEM_ZLIB" "1") | |
178 | #t)) | |
179 | (add-before 'build 'configure-compiler | |
180 | (lambda _ | |
181 | (substitute* '("setup.py" "src/python/grpcio/commands.py") | |
182 | (("'cc'") "'gcc'")) | |
183 | #t))))) | |
184 | (inputs | |
185 | `(("c-ares" ,c-ares) | |
186 | ("openssl" ,openssl) | |
187 | ("zlib" ,zlib))) | |
f2c7513d MB |
188 | (propagated-inputs |
189 | `(("python-six" ,python-six))) | |
190 | (home-page "https://grpc.io") | |
191 | (synopsis "HTTP/2-based RPC framework") | |
192 | (description "This package provides a Python library for communicating | |
193 | with the HTTP/2-based RPC framework gRPC.") | |
194 | (license license:asl2.0))) |