gnu: python-grpcio: Move to (gnu packages rpc).
[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 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages rpc)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix git-download)
24 #:use-module (guix download)
25 #:use-module (guix build-system cmake)
26 #:use-module (guix build-system python)
27 #:use-module (gnu packages adns)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages protobuf)
30 #:use-module (gnu packages python)
31 #:use-module (gnu packages python-xyz)
32 #:use-module (gnu packages tls))
33
34 (define-public grpc
35 (package
36 (name "grpc")
37 (version "1.16.1")
38 (outputs '("out" "static"))
39 (source (origin
40 (method git-fetch)
41 (uri (git-reference
42 (url "https://github.com/grpc/grpc.git")
43 (commit (string-append "v" version))))
44 (file-name (git-file-name name version))
45 (sha256
46 (base32
47 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
48 (build-system cmake-build-system)
49 (arguments
50 `(#:tests? #f ; no test target
51 #:configure-flags
52 (list "-DgRPC_ZLIB_PROVIDER=package"
53 "-DgRPC_CARES_PROVIDER=package"
54 "-DgRPC_SSL_PROVIDER=package"
55 "-DgRPC_PROTOBUF_PROVIDER=package"
56 (string-append "-DCMAKE_INSTALL_PREFIX="
57 (assoc-ref %outputs "out"))
58 "-DCMAKE_INSTALL_LIBDIR=lib"
59 (string-append "-DCMAKE_INSTALL_RPATH="
60 (assoc-ref %outputs "out") "/lib")
61 "-DCMAKE_VERBOSE_MAKEFILE=ON")
62 #:phases
63 (modify-phases %standard-phases
64 (add-before 'configure 'configure-shared
65 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
66 (mkdir "../build-shared")
67 (with-directory-excursion "../build-shared"
68 (apply invoke
69 "cmake" "../source"
70 "-DBUILD_SHARED_LIBS=ON"
71 configure-flags)
72 (apply invoke "make"
73 `("-j" ,(number->string (parallel-job-count)))))))
74 (add-after 'install 'install-shared-libraries
75 (lambda _
76 (with-directory-excursion "../build-shared"
77 (invoke "make" "install"))))
78 (add-before 'strip 'move-static-libs
79 (lambda* (#:key outputs #:allow-other-keys)
80 (let ((out (assoc-ref outputs "out"))
81 (static (assoc-ref outputs "static")))
82 (mkdir-p (string-append static "/lib"))
83 (with-directory-excursion
84 (string-append out "/lib")
85 (for-each
86 (lambda (file)
87 (rename-file file
88 (string-append static "/lib/" file)))
89 (find-files "." "\\.a$"))))
90 #t)))))
91 (inputs
92 `(("c-ares" ,c-ares/cmake)
93 ("openssl" ,openssl)
94 ("zlib" ,zlib)))
95 (native-inputs
96 `(("protobuf" ,protobuf)
97 ("python" ,python-wrapper)))
98 (home-page "https://grpc.io")
99 (synopsis "High performance universal RPC framework")
100 (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
101 (RPC) framework that can run in any environment. It can efficiently connect
102 services in and across data centers with pluggable support for load balancing,
103 tracing, health checking and authentication. It is also applicable in last
104 mile of distributed computing to connect devices, mobile applications and
105 browsers to backend services.")
106 (license license:asl2.0)))
107
108 (define-public python-grpcio
109 (package
110 (name "python-grpcio")
111 (version "1.17.1")
112 (source
113 (origin
114 (method url-fetch)
115 (uri (pypi-uri "grpcio" version))
116 (sha256
117 (base32
118 "0qb9y6j83nxa6d4kc60i8yfgdm7a8ms7b54kncjzf5y7nsxp8rzx"))))
119 (build-system python-build-system)
120 (propagated-inputs
121 `(("python-six" ,python-six)))
122 (home-page "https://grpc.io")
123 (synopsis "HTTP/2-based RPC framework")
124 (description "This package provides a Python library for communicating
125 with the HTTP/2-based RPC framework gRPC.")
126 (license license:asl2.0)))