You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins "pollute" the import context. When a plugin is loaded, any .py files are added into the global context.
If multiple plugins define files with the same name, e.g. ui_handler.py, both plugins will point to the same file. This seems to be determined by a first-come-first-serve basis.
The solution to this could be to make use of relative imports. As it stands now, this is not possible, as the modules created by the importlib.util.module_from_spec call in the Plugin constructor do not set a __package__.
I did a quick patch to the dev build like so:
diff --git a/plug.py b/plug.py
index ee53e76b..e2e103cd 100644
--- a/plug.py+++ b/plug.py@@ -71,6 +71,8 @@ class Plugin:
# Replaces older load_module() code. Includes a safety check that the module name is set.
if spec is not None and spec.loader is not None:
module = importlib.util.module_from_spec(spec)
+ if self.folder is not None:+ module.__package__ = self.folder
sys.modules[module.__name__] = module
spec.loader.exec_module(module)
if getattr(module, 'plugin_start3', None):
which resolved the issue locally. This however also raised some deprecation warnings like
I created 2 sample plugins, both containing a load.py and a plugin_dep.py, which returns a string that is used inside the plugins settings page. Download them here: Bug Report Repro
Load the plugins, go to the settings in EDMC. You will see that Both Plugins A and B both load the plugin_dep from A (as it is loaded first).
Expected behavior
plugin A should import A, plugin B should import B.
Plugins should be able to support relative imports, or any way to avoid naming conflicts between plugins. Furthermore, plugins should have a way to opt out of polluting the global imports.
Screenshots
Here you can see the two plugins from the Reproduction Repository running side by side. You can see that both Plugins load the dependency from the A plugin, because it was added first:
Additional context
Please Confirm the Following...
I have checked the Known Issues list to ensure this is not a duplicate
Logs
Please attach both the EDMarketConnector.log and EDMarketConnector-debug.log if available.
You can find these logs at %TEMP%\EDMarketConnector.log and %TEMP%\EDMarketConnector\EDMarketConnector-debug.log
Relevant Excerpt:
2024-12-27 16:07:08.708 UTC - INFO - 13404:140083445705600:13404 protocol.LinuxProtocolHandler.__init__:319: Web server listening on http://localhost:33879/auth
2024-12-27 16:07:08.709 UTC - DEBUG - 13404:140083445705600:13404 EDMarketConnector.setup_killswitches:1989: fetching killswitches...
2024-12-27 16:07:08.709 UTC - INFO - 13404:140083445705600:13404 killswitch.fetch_kill_switches:346: Attempting to fetch kill switches
2024-12-27 16:07:08.768 UTC - INFO - 13404:140083445705600:13404 killswitch.parse_kill_switches:419: Kill switches last updated 18 October 2021
2024-12-27 16:07:08.768 UTC - TRACE - 13404:140083445705600:13404 EDMCLogging.setup_main_list:88: 0 Active Killswitches:
2024-12-27 16:07:08.807 UTC - INFO - 13404:140083445705600:13404 EDMarketConnector.__main__:2209: Overriding tkinter default font to None at size 10
2024-12-27 16:07:08.808 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "coriolis" from "/usr/lib/edmarketconnector/plugins/coriolis.py"
2024-12-27 16:07:08.810 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "eddn" from "/usr/lib/edmarketconnector/plugins/eddn.py"
2024-12-27 16:07:08.823 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "edsm" from "/usr/lib/edmarketconnector/plugins/edsm.py"
2024-12-27 16:07:08.828 UTC - DEBUG - 13404:140083445705600:13404 plugins.edsm.plugin_start3:231: Starting worker thread...
2024-12-27 16:07:08.830 UTC - DEBUG - 13404:140083445705600:13404 plugins.edsm.plugin_start3:235: Done.
2024-12-27 16:07:08.830 UTC - DEBUG - 13404:140083311146688:13409 plugins.edsm.worker:828: Starting...
2024-12-27 16:07:08.830 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "edsy" from "/usr/lib/edmarketconnector/plugins/edsy.py"
2024-12-27 16:07:08.831 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "inara" from "/usr/lib/edmarketconnector/plugins/inara.py"
2024-12-27 16:07:08.840 UTC - DEBUG - 13404:140083445705600:13404 plugins.inara.plugin_start3:206: Starting worker thread...
2024-12-27 16:07:08.840 UTC - DEBUG - 13404:140083302753984:13410 plugins.inara.new_worker:1538: Starting...
2024-12-27 16:07:08.841 UTC - DEBUG - 13404:140083445705600:13404 plugins.inara.plugin_start3:210: Done.
2024-12-27 16:07:08.841 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "spansh_core" from "/usr/lib/edmarketconnector/plugins/spansh_core.py"
2024-12-27 16:07:08.842 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "a_plugin" from "/media/projects/2024-Q4/edmc-bug-imports-poc/a_plugin/load.py"
2024-12-27 16:07:08.842 UTC - INFO - 13404:140083445705600:13404 plug.Plugin.__init__:66: loading plugin "b_plugin" from "/media/projects/2024-Q4/edmc-bug-imports-poc/b_plugin/load.py"
2024-12-27 16:07:08.862 UTC - INFO - 13404:140083445705600:13404 plugins.eddn.EDDNSender.sqlite_queue_v1:211: New 'eddn_queue-v1.db' created
2024-12-27 16:07:08.924 UTC - INFO - 13404:140083445705600:13404 update.check_for_fdev_updates:71: FDEV ID file commodity.csv already up to date.
2024-12-27 16:07:08.929 UTC - INFO - 13404:140083290584768:13411 update.Updater.worker:267: No new version available at this time
2024-12-27 16:07:08.984 UTC - INFO - 13404:140083445705600:13404 update.check_for_fdev_updates:71: FDEV ID file rare_commodity.csv already up to date.
2024-12-27 16:07:08.984 UTC - INFO - 13404:140083445705600:13404 update.Updater.check_for_updates:194: Tried to update bundle FDEV files but failed. Don't worry, this likely isn't important and can be ignored unless you run into other issues. If you're curious: [Errno 13] Permission denied: '/usr/lib/edmarketconnector/FDevIDs'
2024-12-27 16:07:09.008 UTC - DEBUG - 13404:140083445705600:13404 monitor.EDLogs.start:187: Begin...
2024-12-27 16:07:09.058 UTC - INFO - 13404:140083445705600:13404 monitor.EDLogs.start:240: Polling Journal Folder: "/home/waldi/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/Saved Games/Frontier Developments/Elite Dangerous"
2024-12-27 16:07:09.058 UTC - INFO - 13404:140083445705600:13404 monitor.EDLogs.start:241: Start Journal File: "/home/waldi/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/Saved Games/Frontier Developments/Elite Dangerous/Journal.2024-12-23T200713.01.log"
2024-12-27 16:07:09.059 UTC - DEBUG - 13404:140083445705600:13404 monitor.EDLogs.start:244: Starting Journal worker thread...
2024-12-27 16:07:09.059 UTC - DEBUG - 13404:140083282192064:13413 monitor.EDLogs.worker:357: Starting on logfile "/home/waldi/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/Saved Games/Frontier Developments/Elite Dangerous/Journal.2024-12-23T200713.01.log"
2024-12-27 16:07:09.059 UTC - DEBUG - 13404:140083445705600:13404 monitor.EDLogs.start:248: Done
2024-12-27 16:07:09.059 UTC - DEBUG - 13404:140083445705600:13404 monitor.EDLogs.start:250: Done.
2024-12-27 16:07:09.060 UTC - DEBUG - 13404:140083282192064:13413 monitor.EDLogs.populate_version_info:1862: Parsed self.state['GameVersion']='4.0.0.1904' into self.version_semantic=Version('4.0.0+1904')
2024-12-27 16:07:09.075 UTC - DEBUG - 13404:140083282192064:13413 monitor.EDLogs.populate_version_info:1862: Parsed self.state['GameVersion']='4.0.0.1904' into self.version_semantic=Version('4.0.0+1904')
2024-12-27 16:07:09.118 UTC - INFO - 13404:140083445705600:13404 update.check_for_fdev_updates:71: FDEV ID file commodity.csv already up to date.
2024-12-27 16:07:09.121 UTC - DEBUG - 13404:140083311146688:13409 plugins.edsm.process_discarded_events:749: Got "events to discard" list, commencing queue consumption...
2024-12-27 16:07:09.181 UTC - INFO - 13404:140083445705600:13404 update.check_for_fdev_updates:71: FDEV ID file rare_commodity.csv already up to date.
See Debug Log File for information on the Debug Log files
The text was updated successfully, but these errors were encountered:
This is part bug-report, part feature-request.
Please complete the following information:
Describe the bug
Relevant Discord Thread: https://discord.com/channels/164411426939600896/726419472772235306/1321660752368766999
Plugins "pollute" the import context. When a plugin is loaded, any
.py
files are added into the global context.If multiple plugins define files with the same name, e.g.
ui_handler.py
, both plugins will point to the same file. This seems to be determined by a first-come-first-serve basis.The solution to this could be to make use of relative imports. As it stands now, this is not possible, as the modules created by the
importlib.util.module_from_spec
call in thePlugin
constructor do not set a__package__
.I did a quick patch to the dev build like so:
which resolved the issue locally. This however also raised some deprecation warnings like
To Reproduce
Steps to reproduce the behavior:
load.py
and aplugin_dep.py
, which returns a string that is used inside the plugins settings page. Download them here: Bug Report Reproplugin_dep
from A (as it is loaded first).Expected behavior
plugin A should import A, plugin B should import B.
Plugins should be able to support relative imports, or any way to avoid naming conflicts between plugins. Furthermore, plugins should have a way to opt out of polluting the global imports.
Screenshots
Here you can see the two plugins from the Reproduction Repository running side by side. You can see that both Plugins load the dependency from the A plugin, because it was added first:
Additional context
Please Confirm the Following...
Logs
Please attach both the EDMarketConnector.log and EDMarketConnector-debug.log if available.
You can find these logs at
%TEMP%\EDMarketConnector.log
and%TEMP%\EDMarketConnector\EDMarketConnector-debug.log
Relevant Excerpt:
See Debug Log File for information on the Debug Log files
The text was updated successfully, but these errors were encountered: