Bug 278266 - comms/py-streamdeck: New port: Python library to control the Elgato Stream Deck
Summary: comms/py-streamdeck: New port: Python library to control the Elgato Stream Deck
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Nuno Teixeira
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-08 21:29 UTC by gatekeeper
Modified: 2024-04-20 22:17 UTC (History)
1 user (show)

See Also:


Attachments
Git patch (3.48 KB, patch)
2024-04-08 21:29 UTC, gatekeeper
no flags Details | Diff
This patch eliminates the .orig file from the created package (3.55 KB, patch)
2024-04-18 19:52 UTC, gatekeeper
no flags Details | Diff
Changes after acomments (3.44 KB, patch)
2024-04-20 19:41 UTC, gatekeeper
no flags Details | Diff
Changes after comments (3.40 KB, patch)
2024-04-20 19:50 UTC, gatekeeper
no flags Details | Diff
Fixed patch including comments and pytest (4.39 KB, patch)
2024-04-20 21:14 UTC, gatekeeper
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description gatekeeper 2024-04-08 21:29:28 UTC
Created attachment 249842 [details]
Git patch

Hi.
I am submitting a patch to include the python library python-elgato-streamdeck, version 0.9.5.

Note 1. this version requires a patch. I have submitted the patch upstream, and it has been merged already upstream; however it will be fixed in the next release (version 0.9.6)

Note 2. i have noticed that the generated PKG file installs everything properly; however, there is a left-over from the packaging system, in particular, I observe the following file: /usr/local/lib/python3.9/site-packages/StreamDeck/Transport/LibUSBHIDAPI.py.orig
In my opinion, this file should not be present in the PKG file; however, I am not sure how I can remove it. Help? Suggestions? :-)

Thanks!
Comment 1 gatekeeper 2024-04-18 19:52:00 UTC
Created attachment 250069 [details]
This patch eliminates the .orig file from the created package

So, after some digging, I found out how to make sure that the .orig file is not part of the PKG file. Therefore, I am submitting a new patch.
Can you please check and if all OK, commit?
Thanks!
Comment 2 Nuno Teixeira freebsd_committer freebsd_triage 2024-04-20 14:08:58 UTC
Hello,

Sugestions:

1. Use PyPI sdist instead of github tarball

2. build, lib, run depends could be corrected to:

BUILD_DEPENDS=  \
    ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_FLAVOR} \
    ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR}
LIB_DEPENDS=    libhidapi.so:comms/hidapi
RUN_DEPENDS=    \
    ${PYTHON_PKGNAMEPREFIX}pillow>=8.1.1:graphics/py-pillow@${PY_FLAVOR}

Doubts:

1. Is 'elgato-' prefix needed? PyPI package is registered as https://pypi.org/project/streamdeck/ without prefix. I did some research at repology.org and found that some linux distros use prefix, others don't.

My opinion is to follow PyPI naming scheme.

2. I'm not familiar with this software but I'm noted that sdist includes a test suite. Could you check the possiblity of including a test target?

Note: PyPI sdist seems to be in DOS encoding and it might be needed USES+=dos2unix.
Comment 3 gatekeeper 2024-04-20 19:41:47 UTC
Created attachment 250111 [details]
Changes after acomments

Hi,

thanks for the suggestions for improvement; Accordingly, I have

1) changed from pulling from github to PyPI

2) corrected the build, lib, run depends, as suggested

3) included USES dos2unix (yes, it was required)

For the name of the port, I am fine with having it py-streamdeck. Initially I just used the name from github. It probably is better to have only py-streamdeck, as the library, in the future, might support additional hardware, and therefore not be bound only to Elgato devices. Note: I guess that the title of the bug report should also be changed. I will check if I can do this.

I have included the tests, as suggested. The tests do not use "conventional" python unit tests. I was able to check that the tests are running properly with 1) running with "make test", and 2) adding a patch that makes the tests break and re-run "make test" and confirming that the tests break. NOTE - of course I did not include the "breaking patch" in the attached file :-) it was only for testing.
Comment 4 gatekeeper 2024-04-20 19:50:35 UTC
Created attachment 250112 [details]
Changes after comments

Sorry - my bad.
This new patch includes a small fix to the previous patch, to remove a portlint warning:

WARN: Makefile: DISTNAME is ${PORTNAME}-${PORTVERSION} by default, you don't need to define DISTNAME.
0 fatal errors and 1 warning found.
Comment 5 Nuno Teixeira freebsd_committer freebsd_triage 2024-04-20 20:03:38 UTC
All good.

While we are here, could you give a try running pytest on test.py?

My results are:

---
platform freebsd15 -- Python 3.9.18, pytest-7.4.4, pluggy-1.4.0
rootdir: /wrkdirs/usr/ports/comms/py-streamdeck/work-py39/streamdeck-0.9.5
collected 3 items

test.py EEE                                                                                                                                                                                                  [100%]

====================================================================================================== ERRORS ======================================================================================================
________________________________________________________________________________________ ERROR at setup of test_pil_helpers ________________________________________________________________________________________
file /wrkdirs/usr/ports/comms/py-streamdeck/work-py39/streamdeck-0.9.5/test/test.py, line 22
  def test_pil_helpers(deck):
E       fixture 'deck' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.
---

Really curious where do we get "fixture 'deck' not found" from.

But maybe this could mean that test suite is supported by pytest.

Best method to do this test is using USE_PYTHON+=pytest and additional depends to TEST_DEPENDS.
Comment 6 Nuno Teixeira freebsd_committer freebsd_triage 2024-04-20 20:04:24 UTC
(In reply to gatekeeper from comment #4)

Don't worry about that. We fix it when port is ready.
Comment 7 gatekeeper 2024-04-20 21:14:51 UTC
Created attachment 250114 [details]
Fixed patch including comments and pytest

Thanks for the hint.

I found out that the error comes directly from pytest - the root cause is that the test function requires an argument, and pytest calls this a fixture / requires a fixture to be able to properly call the function.

I have made some changes to the test.py file and now the tests should be running properly :-)
Comment 8 Nuno Teixeira freebsd_committer freebsd_triage 2024-04-20 21:50:38 UTC
(In reply to gatekeeper from comment #7)

Well done!
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-04-20 22:16:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e8c02a572f87a9118c02819c75c81bf30ec49c95

commit e8c02a572f87a9118c02819c75c81bf30ec49c95
Author:     gatekeeper <tiago.gasiba@gmail.com>
AuthorDate: 2024-04-20 22:04:04 +0000
Commit:     Nuno Teixeira <eduardo@FreeBSD.org>
CommitDate: 2024-04-20 22:07:19 +0000

    comms/py-streamdeck: New port: Python library to control the Elgato Stream Deck

    - Submitter becomes maintainer

    This is an open source Python 3 library to control an Elgato Stream Deck
    directly, without the official software. This can allow you to create your
    own custom front-ends, such as a custom control front-end for home
    automation software.

    WWW:            https://github.com/abcminiuser/python-elgato-streamdeck
    PR:             278266

 comms/Makefile                                     |  1 +
 comms/py-streamdeck/Makefile (new)                 | 30 ++++++++++++++++++++++
 comms/py-streamdeck/distinfo (new)                 |  3 +++
 ...-src_StreamDeck_Transport_LibUSBHIDAPI.py (new) | 10 ++++++++
 comms/py-streamdeck/files/patch-test_test.py (new) | 19 ++++++++++++++
 comms/py-streamdeck/pkg-descr (new)                |  4 +++
 6 files changed, 67 insertions(+)
Comment 10 Nuno Teixeira freebsd_committer freebsd_triage 2024-04-20 22:17:39 UTC
Committed, thanks!