~ruther/guix-local

bca7df248fdb3003df8eb50edace51d310047103 — Nicolas Graves 2 months ago 3369218
gnu: python-dbusmock: Update to 0.37.2.

* gnu/packages/python-xyz.scm
(python-dbusmock-check-phase): New variable, to reduce redundancy;
(python-dbusmock): Update to 0.37.2.
[source]: Switch to git-fetch.
[build-system]: Switch to pyproject-build-system.
[arguments]: Migrate them to pyproject-build-system.
<#:phases>: In phase 'patch-path, remove unecessary substitution. Use
python-dbusmock-check-phase.
[native-inputs]: Add python-setuptools.
(python-dbusmock-minimal)[source, arguments, build-system, inputs]:
Adapt fields to keep the same derivation and avoid rebuilds.

Change-Id: I6db0afffc74388fe19025457d7699993e2218666
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Signed-off-by: Rutherther <rutherther@ditigal.xyz>
1 files changed, 85 insertions(+), 55 deletions(-)

M gnu/packages/python-xyz.scm
M gnu/packages/python-xyz.scm => gnu/packages/python-xyz.scm +85 -55
@@ 29217,78 29217,108 @@ Its algorithms are based on the kakasi library, which is written in C.")
implementation of the D-Bus protocol.")
    (license license:expat)))

(define python-dbusmock-check-phase
  #~(lambda* (#:key tests? #:allow-other-keys)
      (when tests?
        (match (primitive-fork)
          (0 ;child process
           (execlp "pytest" "pytest" "-vv"))
          (pytest-pid
           (let loop ()
             ;; Reap child processes; otherwise, python-dbusmock
             ;; would waste time polling for the dbus processes
             ;; it spawns to be reaped, in vain.
             (match (waitpid WAIT_ANY)
               ((pid . status)
                (if (= pid pytest-pid)
                    (unless (zero? status)
                      (error "`pytest' exited with status"
                             status))
                    (loop))))))))))

(define-public python-dbusmock
  (package
    (name "python-dbusmock")
    (version "0.30.0")
    (version "0.37.2")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "python-dbusmock" version))
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/martinpitt/python-dbusmock")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1hanz6x76jq66ypdirga5h15zjs67kwysl6rmsf0i22dbdqrxdfv"))))
    (build-system python-build-system)
        (base32 "1a70gi3qgjblg9z9id9z0fy3vlhb1cqbmmny14bqhv79qqskspj3"))))
    (build-system pyproject-build-system)
    (arguments
     (list #:modules `((guix build python-build-system)
                       (guix build utils)
                       (ice-9 match))

           #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'patch-paths
                 (lambda* (#:key inputs #:allow-other-keys)
                   (substitute* "tests/test_api.py"
                     (("/usr/bin/python3")
                      (which "python3")))
                   (substitute* "tests/test_code.py"
                     (("/bin/bash")
                      (which "bash")))
                   (substitute* "dbusmock/testcase.py"
                     (("'dbus-daemon'")
                      (object->string
                       (search-input-file inputs "/bin/dbus-daemon"))))))
               (replace 'check
                 (lambda* (#:key tests? #:allow-other-keys)
                   (when tests?
                     (match (primitive-fork)
                       (0 ;child process
                        (execlp "pytest" "pytest" "-vv"))
                       (pytest-pid
                        (let loop ()
                          ;; Reap child processes; otherwise, python-dbusmock
                          ;; would waste time polling for the dbus processes
                          ;; it spawns to be reaped, in vain.
                          (match (waitpid WAIT_ANY)
                            ((pid . status)
                             (if (= pid pytest-pid)
                                 (unless (zero? status)
                                   (error "`pytest' exited with status"
                                          status))
                                 (loop)))))))))))))
    (native-inputs
     (list dbus python-pytest upower which))
    (inputs
     (list dbus))
    (propagated-inputs
     (list python-dbus-python python-pygobject))
     (list
      #:modules `((guix build pyproject-build-system)
                  (guix build utils)
                  (ice-9 match))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'patch-paths
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "tests/test_api.py"
                (("/usr/bin/python3")
                 (which "python3")))
              (substitute* "dbusmock/testcase.py"
                (("\"dbus-daemon\"")
                 (object->string
                  (search-input-file inputs "/bin/dbus-daemon"))))))
          (replace 'check #$python-dbusmock-check-phase))))
    (native-inputs (list python-pytest python-setuptools upower which))
    (inputs (list dbus))
    (propagated-inputs (list python-dbus-python python-pygobject))
    (home-page "https://github.com/martinpitt/python-dbusmock")
    (synopsis "Python library for mock D-Bus objects")
    (description "python-dbusmock allows for the easy creation of mock objects on
D-Bus.  This is useful for writing tests for software which talks to D-Bus
services such as upower, systemd, logind, gnome-session or others, and it is
hard (or impossible without root privileges) to set the state of the real
services to what you expect in your tests.")
    (description
     "python-dbusmock allows for the easy creation of mock objects on D-Bus.
This is useful for writing tests for software which talks to D-Bus services
such as upower, systemd, logind, gnome-session or others, and it is hard (or
impossible without root privileges) to set the state of the real services to
what you expect in your tests.")
    (license license:lgpl3+)))

(define-public python-dbusmock-minimal
  (package
    (inherit python-dbusmock)
    (name "python-dbusmock-minimal")
    (version "0.30.0")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "python-dbusmock" version))
       (sha256
        (base32
         "1hanz6x76jq66ypdirga5h15zjs67kwysl6rmsf0i22dbdqrxdfv"))))
    (build-system python-build-system)
    (arguments
     (substitute-keyword-arguments (package-arguments python-dbusmock)
       ((#:tests? _ #t) #f)))
     (list
      #:tests? #f
      #:modules `((guix build python-build-system)
                  (guix build utils)
                  (ice-9 match))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'patch-paths
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "tests/test_api.py"
                (("/usr/bin/python3")
                 (which "python3")))
              (substitute* "tests/test_code.py"
                (("/bin/bash")
                 (which "bash")))
              (substitute* "dbusmock/testcase.py"
                (("'dbus-daemon'")
                 (object->string
                  (search-input-file inputs "/bin/dbus-daemon"))))))
          (replace 'check #$python-dbusmock-check-phase))))
    (native-inputs (list which))
    (inputs
     (list dbus))
    (propagated-inputs
     (list python-dbus-python python-pygobject))
    (properties '((hidden? . #t)))))

(define-public python-jsonplus