WolfgangFahl / py-3rdparty-mediawiki

Wrapper for pywikibot and mwclient MediaWiki API librarties with improvements for 3rd party wikis
Apache License 2.0
4 stars 5 forks source link

make tkinter dependency optional (only import on use) #71

Closed WolfgangFahl closed 2 years ago

WolfgangFahl commented 3 years ago

If the import is done on module load downstream projects might fail even if not using the selector

Traceback (most recent call last):
  File "corpus/lookup.py", line 11, in <module>
    from datasources.openresearch import OREventManager,OREventSeriesManager
  File "/Users/wf/Documents/pyworkspace/ConferenceCorpus/datasources/openresearch.py", line 7, in <module>
    from wikifile.wikiFileManager import WikiFileManager
  File "/Users/wf/Library/Python/3.8/lib/python/site-packages/wikifile/wikiFileManager.py", line 5, in <module>
    from wikibot.wikipush import WikiPush
  File "/Users/wf/Library/Python/3.8/lib/python/site-packages/wikibot/wikipush.py", line 7, in <module>
    from wikibot.selector import Selector
  File "/Users/wf/Library/Python/3.8/lib/python/site-packages/wikibot/selector.py", line 5, in <module>
    from tkinter import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
WolfgangFahl commented 2 years ago

Regression?

Traceback (most recent call last):
  File "/usr/local/bin/wikiquery", line 5, in <module>
    from wikibot.wikipush import mainQuery
  File "/usr/local/lib/python3.8/dist-packages/wikibot/wikipush.py", line 7, in <module>
    from wikibot.selector import Selector
  File "/usr/local/lib/python3.8/dist-packages/wikibot/selector.py", line 5, in <module>
    from tkinter import *
ModuleNotFoundError: No module named 'tkinter'