Python Entry Points Explained

  • I highly recommend reading Stevedore package's excellent documentation [1] to see practical examples of how entry points can be used as a plugin manager in applications.

    [1] - https://docs.openstack.org/stevedore/latest/index.html

  • Entry points are excellent at making your scripts start slooooooooow.

    Compare

      $ time python -m pyflakes /dev/null
      
      real	0m0.225s
      user	0m0.103s
      sys	0m0.008s
    
    with

      $ time pyflakes /dev/null
      
      real	0m2.468s
      user	0m1.738s
      sys	0m0.055s

  • Way too much ink wasted on cuteness and too little on explanation.

    I got stumped at:

    "In particular, the magic happens in get_sneks. The call to pkg_resources.iter_entry_points('snek_types') iterates over all the entry points that were registered under the name "snek_types". So, external packages can define an entry point called "snek_types" in their setup.py, and snek will dynamically load it at runtime."

    Wait. What entry points were registered under the name "snek_types"? Where were they regeistered as such? I think I must be missing something, or maybe that registration was hidden somewhere among all the fancy snakes. Can someone help explain this in a clearer way?

  • What is the actual value of entry points over just marking a script +x and putting somewhere on the path? All I see is a bunch of added complexity.