Subject: [bug#56298] [PATCH 7/7] gnu: Add python-cmsis-pack-manager.

From: [email-masked]
Date: Wed, 29 Jun 2022 10:46:33 -0400

From: Peter Polidoro <[email-masked]>

* gnu/packages/embedded.scm (python-cmsis-pack-manager): New variable.
---
 gnu/packages/embedded.scm | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 6a66fe4753..07087b0feb 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2021 Morgan Smith <[email-masked]>
 ;;; Copyright © 2022 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2022 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2022 Peter Polidoro <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,6 +36,7 @@ (define-module (gnu packages embedded)
   #:use-module (guix svn-download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
@@ -48,6 +50,7 @@ (define-module (gnu packages embedded)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages crates-io)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages dejagnu)
   #:use-module (gnu packages flex)
@@ -65,6 +68,7 @@ (define-module (gnu packages embedded)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages rust)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages version-control)
@@ -1580,6 +1584,83 @@ (define-public python-psptool
     (description "PSPTool is a tool for dealing with AMD binary blobs")
     (license license:gpl3+)))
 
+(define-public python-cmsis-pack-manager
+  (package
+    (name "python-cmsis-pack-manager")
+    (version "0.4.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/pyocd/cmsis-pack-manager")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0gv8qnk4qfffa6pshm85jh5wi4rf2pfrxn2jdj8wa19adzdwnwag"))))
+    (build-system python-build-system)
+    (arguments
+     (list
+      #:imported-modules (append %cargo-build-system-modules
+                                 %python-build-system-modules)
+      #:modules `(((guix build cargo-build-system) #:prefix cargo:)
+                  ,@%python-build-system-modules
+                  (srfi srfi-1)
+                  (ice-9 match))
+      ;; #:phases
+      ;; #~(modify-phases (@ (guix build python-build-system) %standard-phases)
+      ;;     (add-before 'build 'configure-cargo
+      ;;       (lambda* (#:key inputs #:allow-other-keys)
+      ;;         ;; Hide irrelevant inputs from cargo-build-system so it does
+      ;;         ;; not try to unpack sanity-check.py, etc.
+      ;;         (let ((cargo-inputs (filter (match-lambda
+      ;;                                       ((name . path)
+      ;;                                        (or (string-prefix? "rust-" name)
+      ;;                                            (string=? "gcc" name))))
+      ;;                                     inputs)))
+      ;;           (with-directory-excursion "rust"
+      ;;             ((assoc-ref cargo:%standard-phases 'unpack-rust-crates)
+      ;;              #:inputs cargo-inputs
+      ;;              #:vendor-dir "guix-vendor")
+      ;;             ((assoc-ref cargo:%standard-phases 'configure)
+      ;;              #:inputs cargo-inputs)
+      ;;             ((assoc-ref cargo:%standard-phases 'patch-cargo-checksums)
+      ;;              #:vendor-dir "guix-vendor"))
+      ;;           (rename-file "rust/.cargo" ".cargo"))))
+      ;;     (replace 'check
+      ;;       (lambda* (#:key tests? #:allow-other-keys)
+      ;;         (when tests?
+      ;;           (invoke "pytest" "-vv" "tests"))))
+      ;;     )
+      ))
+    (inputs (list rust-anyhow-1
+                  rust-bytes-1
+                  rust-futures-0.3
+                  rust-log-0.4
+                  rust-loom-0.5
+                  rust-minidom-0.12
+                  rust-reqwest-0.11
+                  rust-rustc-demangle-0.1
+                  rust-serde-1
+                  rust-serde-json-1
+                  rust-tokio-1))
+    (propagated-inputs (list python-appdirs
+                             python-milksnake
+                             python-pyyaml))
+    (native-inputs (list python-hypothesis
+                         python-jinja2
+                         python-mock
+                         python-pytest
+                         rust
+                         `(,rust "cargo")))
+    (home-page "https://github.com/pyocd/cmsis-pack-manager")
+    (synopsis
+     "Python manager for CMSIS-Pack index and cache with Rust backend")
+    (description
+     "This package provides a python module, Rust crate, and command line utility
+for managing current device information that is stored in many Common
+Microcontroller Software Interface Standard (CMSIS) Packs.")
+    (license license:asl2.0)))
+
 (define-public agent-proxy
   (let ((commit "8927798a71d246871ea8fc22b4512296a3fa1765")
         (revision "0"))
-- 
2.36.1