Skip to content

Commit

Permalink
Discover hidden IPv8 module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Oct 16, 2020
1 parent cad39cb commit 62108df
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/tribler-core/tribler_core/modules/ipv8_module_catalog.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import inspect
import sys

from ipv8.loader import CommunityLauncher, after, kwargs, overlay, precondition, set_in_session, walk_strategy
from ipv8.peer import Peer

Expand Down Expand Up @@ -161,6 +164,18 @@ class RemoteQueryTestnetCommunityLauncher(TestnetMixIn, RemoteQueryCommunityLaun
pass


def get_hiddenimports():
"""
Return the set of all hidden imports defined by all CommunityLaunchers in this file.
"""
hiddenimports = set()

for _, obj in inspect.getmembers(sys.modules[__name__]):
hiddenimports.update(getattr(obj, "hiddenimports", set()))

return hiddenimports


def register_default_launchers(loader):
"""
Register the default CommunityLaunchers into the given CommunityLoader.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tribler_core.modules.ipv8_module_catalog import get_hiddenimports


def test_hiddenimports():
"""
Check if all hidden imports are detected
"""
hiddenimports = get_hiddenimports()

assert 'anydex.core.community' in hiddenimports
assert 'ipv8.attestation.trustchain.community' in hiddenimports
assert 'ipv8.dht.churn' in hiddenimports
assert 'ipv8.dht.discovery' in hiddenimports
assert 'ipv8.peerdiscovery.churn' in hiddenimports
assert 'ipv8.peerdiscovery.community' in hiddenimports
assert 'ipv8.peerdiscovery.discovery' in hiddenimports
assert 'tribler_core.modules.popularity.popularity_community' in hiddenimports
assert 'tribler_core.modules.metadata_store.community.gigachannel_community' in hiddenimports
assert 'tribler_core.modules.metadata_store.community.remote_query_community' in hiddenimports
assert 'tribler_core.modules.metadata_store.community.sync_strategy' in hiddenimports
assert 'tribler_core.modules.tunnel.community.discovery' in hiddenimports
assert 'tribler_core.modules.tunnel.community.triblertunnel_community' in hiddenimports
4 changes: 3 additions & 1 deletion tribler.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ for component in tribler_components:
from tribler_core.version import version_id
version_str = version_id.split('-')[0]

from tribler_core.modules.ipv8_module_catalog import get_hiddenimports as ipv8_module_imports

# On macOS, we always show the console to prevent the double-dock bug (although the OS does not actually show the console).
# See https://github.com/Tribler/tribler/issues/3817
show_console = os.environ.get('SHOW_CONSOLE', 'false') == 'true'
Expand Down Expand Up @@ -83,7 +85,7 @@ hiddenimports = [
'pkg_resources', 'pkg_resources.py2_warn', # Workaround PyInstaller & SetupTools, https://github.com/pypa/setuptools/issues/1963
'requests',
'PyQt5.QtTest',
'pyqtgraph'] + widget_files + pony_deps
'pyqtgraph'] + widget_files + pony_deps + list(ipv8_module_imports())


sys.modules['FixTk'] = None
Expand Down

0 comments on commit 62108df

Please sign in to comment.