Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use os.pathsep instead of custom implementation #69

Merged
merged 1 commit into from
Mar 7, 2021

Conversation

dneise
Copy link
Contributor

@dneise dneise commented Mar 6, 2021

Hi, I was looking for ways to install plugins outside of comet/plugins, when I stumbled over #63.
Looks like exactly what I need :D .. thanks for that!
(I wish it was possible to avoid such an env-var altogether and just detect plugins in all packages on a system, but I assume that is impossible performance wise? ... )

Anyway I think you can save a line and an import here ... os.pathsep does exactly this for you already:
https://docs.python.org/3/library/os.html#os.pathsep

@jdswinbank jdswinbank merged commit 1309465 into jdswinbank:master Mar 7, 2021
@jdswinbank
Copy link
Owner

Thank you for this!

I wish it was possible to avoid such an env-var altogether and just detect plugins in all packages on a system

While I don't think it's practical to detect plugins in all packages, if you prefer being able to install plugins as packages you might be able to create packages which just contain comet/plugins/{__init__, pluginname}.py and a setup.py that looks something like this:

from distutils.core import setup

setup(
    name="comet plugin test",
    packages=['comet/plugins']
)

Not the same as scanning all packages, but at least you'd be able to manage your plugins using pip, etc.

I confess my knowledge of Python packaging is rusty, so I might be off on the wrong track here; please let me know if the above works for you and if so I can formalize it in the documentation.

@dneise
Copy link
Contributor Author

dneise commented Mar 8, 2021

Hi John, thanks for the quick reply.

I'll have a look if this works ... so far my understanding was, that one package shouldn't write into the installation folder of another package (however I did not read anything super explicit about this topic .. so I might be wrong).

Anyway if this does not work, I guess we'll try to use the PLUGINPATH which is available in the master.

@jdswinbank
Copy link
Owner

You're certainly right that the approach I outline above is ugly... I think it'll work in this case, but no promises.

I'd like to do this “properly” using setuptools entry points (https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html#advertising-behavior). That'll take some more effort to implement, though, and the amount of time I have to spend on Comet is quite limited at the moment. I'll create an issue to experiment with this, and see if I can put something together in a spare moment.

@dneise dneise deleted the pathsep branch March 8, 2021 08:19
@dneise
Copy link
Contributor Author

dneise commented Mar 8, 2021

Good Morning John,

Thanks for pointing me to the entry-point docu .. So far I assumed this was only for console scripts, but now I see this is the way pytest deals with plugins .. interesting.

Btw. if your time is limited, I guess us users of comet can also give something back and try to make a PR with some form of "improved" plugin detection.

Just as a side note, in our analysis pipeline prototype for CTA we do a very simple plugin detection based on a package name prefix.
https://github.com/cta-observatory/ctapipe/blob/d853908cfc6933a6b0a5946a4d77911d00ca4b91/ctapipe/core/plugins.py#L7

I assume we can discuss anything else in #71
Btw, I think it is great that you are open to improve this, even though your time is limited.

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

Successfully merging this pull request may close these issues.

2 participants