How easy_install egg plugin and download it without restarting the application?

I am creating an application that downloads and installs its own egg plugins, but I have a problem loading the eggs after easy_install extracts it into place. Here's how it works now:

  • The application loads the egg in a temporary folder
  • Installs the egg from setuptools.command.easy_install.main () in the ~ / .app / plugins folder (which is indicated by pth on dist-packages)
  • At this point, ~ / .apps / plugins / easy-install.pth is updated with a new egg path

The problem is that pth does not restart until the python process is restarted, which means that the application needs to be stopped and restarted (the application is a lengthy process, and installing the plugin does not require a restart).

So, the question is, how can I either reload pth programmatically so that opening the plugin entry point works for a new egg, or does easy_install somehow return the path to which it installed the egg, so I can manually (with pkg_resources) download the new plugin?

I could create a function that tries to guess the easy_install path or parse pth myself, but I prefer not to, if at all possible.

Python 2.6, setuptools 0.6c9


Thanks to Marius Gedminas , what I'm doing now is basically:

dist = pkg_resources.get_distribution(plugin_name) entry = dist.get_entry_info(entry_point_name, plugin_name) plugin = entry.load() 
+6
python setuptools egg
source share
1 answer

After looking at some documentation, I think you need to do

 pkg_resources.get_distribution(name).activate() 

where name is the name of the package you just installed.

+4
source share

All Articles