10

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?
Benjamin Pollack
  • 27,594
  • 16
  • 81
  • 105

1 Answers1

2
  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

yacc143
  • 375
  • 4
  • 6
  • Thank you! Using your answer I was able to monkey patch `pylibjpeg` like so: `pylibjpeg.utils.iter_entry_points = pkg_resources.WorkingSet(None).iter_entry_points`. This allowed me to run this in a continuous kernel, which is a requirement for Kaggle Code competitions :) – Jonathan Allen Grant Dec 04 '22 at 14:43