46
46
from bzrlib import plugins as _mod_plugins
49
from bzrlib.symbol_versioning import deprecated_function, zero_ninetyone
49
from bzrlib.symbol_versioning import deprecated_function, one_three
50
50
from bzrlib.trace import mutter, warning, log_exception_quietly
57
57
"""Get the DEFAULT_PLUGIN_PATH"""
58
58
global DEFAULT_PLUGIN_PATH
59
59
if DEFAULT_PLUGIN_PATH is None:
60
path = [osutils.pathjoin(config.config_dir(), 'plugins')]
61
if getattr(sys, 'frozen', None): # bzr.exe
62
# We need to use relative path to system-wide plugin
63
# directory because bzrlib from standalone bzr.exe
64
# could be imported by another standalone program
65
# (e.g. bzr-config; or TortoiseBzr/Olive if/when they
66
# will become standalone exe). [bialix 20071123]
67
# __file__ typically is
68
# C:\Program Files\Bazaar\lib\library.zip\bzrlib\plugin.pyc
69
# then plugins directory is
70
# C:\Program Files\Bazaar\plugins
71
# so relative path is ../../../plugins
72
path.append(osutils.abspath(osutils.pathjoin(
73
osutils.dirname(__file__), '../../../plugins')))
74
DEFAULT_PLUGIN_PATH = os.pathsep.join(path)
60
DEFAULT_PLUGIN_PATH = osutils.pathjoin(config.config_dir(), 'plugins')
75
61
return DEFAULT_PLUGIN_PATH
78
@deprecated_function(zero_ninetyone)
80
"""Return a dictionary of the plugins."""
81
return dict((name, plugin.module) for name, plugin in plugins().items())
84
64
def disable_plugins():
85
65
"""Disable loading plugins.
100
80
"""Set the path for plugins to be loaded from."""
101
81
path = os.environ.get('BZR_PLUGIN_PATH',
102
82
get_default_plugin_path()).split(os.pathsep)
83
bzr_exe = bool(getattr(sys, 'frozen', None))
84
if bzr_exe: # expand path for bzr.exe
85
# We need to use relative path to system-wide plugin
86
# directory because bzrlib from standalone bzr.exe
87
# could be imported by another standalone program
88
# (e.g. bzr-config; or TortoiseBzr/Olive if/when they
89
# will become standalone exe). [bialix 20071123]
90
# __file__ typically is
91
# C:\Program Files\Bazaar\lib\library.zip\bzrlib\plugin.pyc
92
# then plugins directory is
93
# C:\Program Files\Bazaar\plugins
94
# so relative path is ../../../plugins
95
path.append(osutils.abspath(osutils.pathjoin(
96
osutils.dirname(__file__), '../../../plugins')))
103
97
# Get rid of trailing slashes, since Python can't handle them when
104
98
# it tries to import modules.
105
99
path = map(_strip_trailing_sep, path)
106
# search the plugin path before the bzrlib installed dir
107
path.append(os.path.dirname(_mod_plugins.__file__))
100
if not bzr_exe: # don't look inside library.zip
101
# search the plugin path before the bzrlib installed dir
102
path.append(os.path.dirname(_mod_plugins.__file__))
108
103
_mod_plugins.__path__ = path
215
207
log_exception_quietly()
210
@deprecated_function(one_three)
218
211
def load_from_zip(zip_name):
219
212
"""Load all the plugins in a zip."""
220
213
valid_suffixes = ('.py', '.pyc', '.pyo') # only python modules/packages
224
216
index = zip_name.rindex('.zip')
225
217
except ValueError: