Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my installed app handle pkg_resources.iter_entry_points differently than in source?

I have a Python app that looks for plugins via pkg_resources.iter_entry_points.

When run directly from source checkout, this will find anything in sys.path that fits the bill, including source checkouts that happen to have an applicable .egg-info for setuptools to find.

Yet when I install the package anywhere via python setup.py install, it suddenly ceases to detect everything enumerated in sys.path, instead only finding things that are installed alongside it in site-packages.

  • Why is pkg_resources.iter_entry_points behaving differently for the vanilla source checkout v. the installed application?
  • How can I make it traverse everything in sys.path, as it does in development?
like image 652
Benjamin Pollack Avatar asked Mar 10 '14 19:03

Benjamin Pollack


1 Answers

  1. How to get it to iterate over sys.path?

    pkg_resources.WorkingSet(None).iter_entry_points

  2. Why does it behave differently? Probably because the installed package forces at least the meta data about itself into memory. Looking at the code, my guess would be that your main module has a requires attribute, but that's only an educated guess. Anyway, to force the "installed" behaviour while developing, it should be enough to run python setup.py develop

like image 69
yacc143 Avatar answered Oct 27 '22 00:10

yacc143