/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugin.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:28:14 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7305.
  • Revision ID: jelmer@jelmer.uk-20190529032814-fzqbrgf9647u9ptq
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        from breezy.plugins import __path__ as path
102
102
 
103
103
    state.plugin_warnings = {}
104
 
    _load_plugins(state, path)
 
104
    _load_plugins_from_path(state, path)
 
105
    if (None, 'entrypoints') in _env_plugin_path():
 
106
        _load_plugins_from_entrypoints(state)
105
107
    state.plugins = plugins()
106
108
 
107
109
 
 
110
def _load_plugins_from_entrypoints(state):
 
111
    try:
 
112
        import pkg_resources
 
113
    except ImportError:
 
114
        # No pkg_resources, no entrypoints.
 
115
        pass
 
116
    else:
 
117
        for ep in pkg_resources.iter_entry_points('breezy.plugin'):
 
118
            fullname = _MODULE_PREFIX + ep.name
 
119
            if fullname in sys.modules:
 
120
                continue
 
121
            sys.modules[fullname] = ep.load()
 
122
 
 
123
 
108
124
def plugin_name(module_name):
109
125
    """Gives unprefixed name from module_name or None."""
110
126
    if module_name.startswith(_MODULE_PREFIX):
205
221
    """Gives list of paths and contexts for plugins from environ key.
206
222
 
207
223
    Each entry is either a specific path to load plugins from and the value
208
 
    'path', or None and one of the three values 'user', 'core', 'site'.
 
224
    'path', or None and one of the values 'user', 'core', 'entrypoints', 'site'.
209
225
    """
210
226
    path_details = []
211
227
    env = osutils.path_from_environ(key)
212
 
    defaults = {"user": not env, "core": True, "site": True}
 
228
    defaults = {"user": not env, "core": True, "site": True, 'entrypoints': True}
213
229
    if env:
214
230
        # Add paths specified by user in order
215
231
        for p in env.split(os.pathsep):
222
238
                path_details.append((p, 'path'))
223
239
 
224
240
    # Add any remaining default paths
225
 
    for name in ('user', 'core', 'site'):
 
241
    for name in ('user', 'core', 'entrypoints', 'site'):
226
242
        if defaults[name]:
227
243
            path_details.append((None, name))
228
244
 
256
272
        sys.meta_path.insert(2, finder)
257
273
 
258
274
 
259
 
def _load_plugins(state, paths):
 
275
def _load_plugins_from_path(state, paths):
260
276
    """Do the importing all plugins from paths."""
261
277
    imported_names = set()
262
278
    for name, path in _iter_possible_plugins(paths):