guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/05: gnu: Add python-mypy-protobuf.


From: guix-commits
Subject: 04/05: gnu: Add python-mypy-protobuf.
Date: Wed, 31 Aug 2022 23:17:35 -0400 (EDT)

apteryx pushed a commit to branch master
in repository guix.

commit 1a7fb20e8c50b56083a3196b37ef570ab8b7cc6e
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Wed Aug 31 15:55:48 2022 -0400

    gnu: Add python-mypy-protobuf.
    
    * gnu/packages/protobuf.scm (python-mypy-protobuf): New variable.
---
 gnu/packages/protobuf.scm | 66 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]