0

I am working on a module that may or may not be loaded from an egg file, and for each case, there should be a different action (setting up of the module).

What is the best way to detect if the current module was loaded from an egg file or directly from the source?

romaia
  • 403
  • 3
  • 6
  • 2
    Why do you think you need to handle loading from an egg differently? Perhaps your problem can be solved by using [`pkg_resources`](https://pythonhosted.org/setuptools/pkg_resources.html) instead? – Martijn Pieters Sep 02 '14 at 18:46
  • Also, which version of Python and `setuptools` you're using/requiring would be really helpful here. – abarnert Sep 02 '14 at 18:54
  • I am using python 2.7, and yes, I am trying to detect if its an egg so that I can use pkg_resources.resource_string() to load a file from the egg, otherwise, I will load it directly. Unless I missed something and pkg_resources can handle both cases. – romaia Sep 02 '14 at 19:10
  • @romaia: `pkg_resources` can handle both cases. That's part of the point of the module. – Martijn Pieters Sep 02 '14 at 19:14

0 Answers0