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