Subject: [bug#41455] [PATCH 1/2] gnu: Add python-libtmux

From: Marius Bakke <[email-masked]>
Date: Tue, 26 May 2020 00:43:10 +0200

Edouard Klein <[email-masked]> writes:

> * gnu/packages/check.scm (python-pytest-4): New variable.
> * gnu/packages/tmux.scm (python-libtmux): New variable.

Thanks!  Can you submit these as two separate patches?

> +    (native-inputs
> +     `(("python-setuptools-scm" ,python-setuptools-scm)
> +       ("git" ,git)))
> +    (arguments `(#:phases
> +                 (modify-phases %standard-phases
> +                   (add-after 'unpack 'git-tag
> +                     (lambda _
> +                       ;; setuptools-scm needs to know the version
> +                       (invoke "git" "init")
> +                       (invoke "git" "add" ".")
> +                       (invoke "git" "config" "user.name" "John Doe")
> +                       (invoke "git" "config" "user.email" "[email-masked]")
> +                       (invoke "git" "commit" "-m" "dummy commit")
> +                       (invoke "git" "tag" ,version))))))

This is weird, we haven't needed this before.  Is there a way to avoid
the dependency on git here?  In the worst case maybe we can create
".git/refs/tags/,version" manually?  :-/

Also, please make this inherit from pytest instead of duplicating all
the fields.

[...]
  
> +(define-public python-libtmux
> +  (package
> +    (name "python-libtmux")
> +    (version "0.8.2")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       ;; Pypi source tarball does not include tests
> +       (uri (git-reference
> +             (url "https://github.com/tmux-python/libtmux.git")
> +             (commit (string-append "v" version))))
> +       (file-name "python-libtmux")
> +       (sha256
> +        (base32
> +         "1akjv6aqpc690c4l2cjh0fxbpxxg63sfjggapfjjjaqmcl38g1dz"))))
> +    (build-system python-build-system)
> +    (propagated-inputs
> +     `(("python-pytest-4" ,python-pytest-4)

Do you know if pytest 4 is really needed?  Often Python packages pin a
specific version for no good reason, and one can simply substitute "=="
with ">=" in setup.py and it's all good.

> +       ("tmux" ,tmux)

Even though this is useless without tmux, I'm not sure if we should
propagate it.  Some users might have custom versions of tmux, but would
still want to use this library.  WDYT?

> +       ("procps" ,procps)))  ;; Tests need top

                                ^ only one semicolon for margin comments
                                ;typically without a space, like this

> +    (arguments
> +     `(#:phases
> +       (modify-phases %standard-phases
> +         (replace 'check
> +           (lambda _
> +             ;; Extend PYTHONPATH so the built package will be found.
> +             (setenv "PYTHONPATH"
> +                     (string-append (getcwd) "/build/lib:"
> +                                    (getenv "PYTHONPATH")))
> +             ;; Skip tests that I suspect fail because of a change
> +             ;; in behavior in tmux 3 from tmux 2
> +             ;; https://github.com/tmux-python/libtmux/issues/281
> +             (invoke "pytest" "-vv" "-k"
> +                     (string-append "not test_show_option_unknown "
> +                                    "and not test_show_window_option_unknown"))
> +             #t)))))
> +    (home-page
> +     "https://github.com/tmux-python/libtmux")

This line break is unnecessary.

Otherwise looks good.  Can you send updated patches?