Jorge E. Cardona
Jorge E. Cardona

Reputation: 95448

Is there a way to execute some task after a python package was installed according to some entry_point defined?

I want to know if there is a way to register some special entry_point and executes some task when the package is installed and has that entry_point defined, pretty much like console_scripts, I imagine is distutils the one that execute the tasks,but there is a way to register more tasks according to some entry_point?

At the end I want to execute something like a post-install task but not defined in the package but in another one.

The way I'm doing this right now is to monitor the pkg_resources.iter_entry_points every x seconds, and reload the package pkg_resources to get the new entry_points and do the action when someone defines one new, I'm doing this in a daemon, but it seems that there should be a better way to do this.

Upvotes: 0

Views: 64

Answers (1)

Senthil Kumaran
Senthil Kumaran

Reputation: 56881

Yes, you can create your own entry points similar to the console scripts. You can define the entry points as anything you want and can use pkg_resources.iter_entry_points method to act upon that definition, which will be called in the same manner as console_scripts. Here are two good resources on this subject.

Upvotes: 1

Related Questions