Webdev/Meetings/2014/July 1: Difference between revisions

→‎The Bikeshed / Roundtable: Add entry points thing.
(Added my stuff.)
(→‎The Bikeshed / Roundtable: Add entry points thing.)
Line 53: Line 53:
             print num_done, 'of', num_jobs, 'jobs done.'
             print num_done, 'of', num_jobs, 'jobs done.'
             yield future
             yield future
* (ErikRose) [https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins Setuptools entry points] are underdocumented but a really nice, easy, supported-everywhere way to do a plugin architecture, even an internal registry.
    # setup.py
    setup(
        ...
        entry_points={'dxr.plugins': ['urllink = dxr.plugins.urllink',
                                      'buglink = dxr.plugins.buglink']}
    )
   
    # elsewhere.py
    plugins = dict((point.name, point.load()) for point in
                  iter_entry_points('dxr.plugins'))
   
    # plugins is now {'urllink': <module dxr.plugins.urllink>,
    #                'buglink': <module dxr.plugins.buglink>}
Confirmed users
574

edits