Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

We should look up the current directory name to import from dynamically #4

Open
sersorrel opened this issue Jun 8, 2021 · 1 comment

Comments

@sersorrel
Copy link
Owner

See inorton/EDMCHits#23. If the directory we're in is not called exactly edmcoverlay, we'll fail to import ourselves – this is great in that it errors out if we get cloned as edmcoverlay2, but we probably need to support being called both edmcoverlay and EDMCOverlay, since the case difference typically matters on Linux but not on Windows.

@sersorrel
Copy link
Owner Author

This is now implemented, but only one instance of the plugin can be loaded at once, so its usefulness is limited.

It might ultimately be a better approach to install a shim package under the name EDMCOverlay (and any other names used) which just reexports this plugin. This either makes the install process more complicated, or means that the plugin won't necessarily work on the first run, if a plugin that uses EDMC Overlay under a differently-capitalised name is loaded before us; uninstallation is also either made more complicated, or more risky (e.g. if the shims delete themselves if edmcoverlay is unavailable). Or the shims can just stay there forever and exit silently if edmcoverlay can't be imported.

We could just modify sys.path directly to avoid polluting the plugins directory, but this means that for at least some plugins (those with an __init__.py that happen to be returned before us by os.listdir), the alternate names won't ever be available.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant