From 15cb66462136ff46fc0d8ae38478e0ebf4734907 Mon Sep 17 00:00:00 2001 From: eric15342335 <70310617+eric15342335@users.noreply.github.com> Date: Sat, 7 Aug 2021 23:56:34 +0800 Subject: [PATCH] hooks: add hook for pystray (#288) --- news/288.new.rst | 1 + requirements-test-libraries.txt | 1 + .../hooks/stdhooks/hook-pystray.py | 16 ++++++++++++++++ .../tests/test_libraries.py | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 news/288.new.rst create mode 100644 src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pystray.py diff --git a/news/288.new.rst b/news/288.new.rst new file mode 100644 index 00000000..77b9f282 --- /dev/null +++ b/news/288.new.rst @@ -0,0 +1 @@ +Add a hook for ``pystray`` to collect hidden imports. diff --git a/requirements-test-libraries.txt b/requirements-test-libraries.txt index f4a38e37..6e481f82 100644 --- a/requirements-test-libraries.txt +++ b/requirements-test-libraries.txt @@ -29,6 +29,7 @@ pyexcelerate==0.8.0 pylint==2.4.4 pyusb==1.0.2 pynput==1.7.3 +pystray==0.17.3 pyzmq==22.0.3 sentry-sdk==0.19.3 # shotgun_api3 can only be installed from git diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pystray.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pystray.py new file mode 100644 index 00000000..d7e20e62 --- /dev/null +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pystray.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------ +# Copyright (c) 2020 PyInstaller Development Team. +# +# This file is distributed under the terms of the GNU General Public +# License (version 2.0 or later). +# +# The full license is available in LICENSE.GPL.txt, distributed with +# this software. +# +# SPDX-License-Identifier: GPL-2.0-or-later +# ------------------------------------------------------------------ + +from PyInstaller.utils.hooks import collect_submodules +# https://github.com/moses-palmer/pystray/tree/feature-explicit-backends +# if this get merged then we don't need this hook +hiddenimports = collect_submodules("pystray") diff --git a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py index 8f43f98b..8d4ef451 100644 --- a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py +++ b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py @@ -664,3 +664,10 @@ def test_pynput(pyi_builder): pyi_builder.test_source(""" import pynput """) + + +@importorskip('pystray') +def test_pystray(pyi_builder): + pyi_builder.test_source(""" + import pystray + """)