aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-08-31 15:55:48 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-08-31 23:13:46 -0400
commit1a7fb20e8c50b56083a3196b37ef570ab8b7cc6e (patch)
treebf5ca374089e73a6d9cd1e2184b1cae7326ff4d5 /gnu
parent1898c6c2970c6dcec0ced2f7d9dfc936ae33c12a (diff)
downloadguix-1a7fb20e8c50b56083a3196b37ef570ab8b7cc6e.tar.gz
guix-1a7fb20e8c50b56083a3196b37ef570ab8b7cc6e.zip
gnu: Add python-mypy-protobuf.
* gnu/packages/protobuf.scm (python-mypy-protobuf): New variable.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/protobuf.scm66
1 files changed, 66 insertions, 0 deletions
diff --git a/gnu/packages/protobuf.scm b/gnu/packages/protobuf.scm
index baa7f55d9c..a61d9d7492 100644
--- a/gnu/packages/protobuf.scm
+++ b/gnu/packages/protobuf.scm
@@ -46,6 +46,7 @@
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-check)
#:use-module (gnu packages python-xyz)
+ #:use-module (gnu packages rpc)
#:use-module (gnu packages ruby))
(define-public fstrm
@@ -271,6 +272,71 @@ in ansi C. It is especially suitable for use in microcontrollers, but fits
any memory-restricted system.")
(license license:zlib)))
+(define-public python-mypy-protobuf
+ (package
+ (name "python-mypy-protobuf")
+ (version "3.3.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nipunn1313/mypy-protobuf")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0z03h9k68qvnlyhpk0ndwp01bdx77vrjr6mybxq4ldilkkbksklk"))))
+ (build-system python-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ ;; XXX: PEP 517 manual build copied from python-isort.
+ (replace 'build
+ (lambda _
+ ;; ZIP does not support timestamps before 1980.
+ (setenv "SOURCE_DATE_EPOCH" "315532800")
+ (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
+ (replace 'install
+ (lambda _
+ (let ((whl (car (find-files "dist" "\\.whl$"))))
+ (invoke "pip" "--no-cache-dir" "--no-input"
+ "install" "--no-deps" "--prefix" #$output whl))))
+ (add-before 'check 'generate-protos-for-tests
+ (lambda _
+ ;; Generate Python sources.
+ (for-each (lambda (proto)
+ (invoke "protoc"
+ "--proto_path=proto"
+ "--experimental_allow_proto3_optional"
+ "--python_out=test/generated" proto))
+ (find-files "." "\\.proto$"))
+ ;; Generate GRPC protos.
+ (for-each (lambda (proto)
+ (invoke "python" "-m" "grpc_tools.protoc"
+ "--proto_path=proto"
+ "--experimental_allow_proto3_optional"
+ "--grpc_python_out=test/generated" proto))
+ (find-files "proto/testproto/grpc" "\\.proto$"))))
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (setenv "PYTHONPATH" "test/generated")
+ (invoke "pytest" "-vv" "--ignore=test/generated" "test"))))))
+ (native-inputs
+ (list python-grpc-stubs
+ python-grpcio-tools
+ python-pypa-build
+ python-pytest
+ python-typing-extensions-next))
+ (propagated-inputs
+ (list protobuf
+ python-protobuf
+ python-types-protobuf))
+ (home-page "https://github.com/nipunn1313/mypy-protobuf")
+ (synopsis "Generate Mypy stub files from protobuf specifications")
+ (description "This Python package provide tools to generate Mypy stubs
+from protobuf specification files.")
+ (license license:asl2.0)))
+
(define-public python-nanopb
(package
(inherit nanopb)