/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 bzrlib/plugin.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    """Get the DEFAULT_PLUGIN_PATH"""
58
58
    global DEFAULT_PLUGIN_PATH
59
59
    if DEFAULT_PLUGIN_PATH is None:
60
 
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(config.config_dir(), 'plugins')
 
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)
61
75
    return DEFAULT_PLUGIN_PATH
62
76
 
63
77
 
77
91
    global _loaded
78
92
    _loaded = True
79
93
 
 
94
 
80
95
def _strip_trailing_sep(path):
81
96
    return path.rstrip("\\/")
82
97
 
 
98
 
83
99
def set_plugins_path():
84
100
    """Set the path for plugins to be loaded from."""
85
101
    path = os.environ.get('BZR_PLUGIN_PATH',
141
157
        else:
142
158
            # it might be a zip: try loading from the zip.
143
159
            load_from_zip(d)
144
 
            continue
145
160
 
146
161
 
147
162
# backwards compatability: load_from_dirs was the old name
375
390
        if getattr(self.module, '__path__', None) is not None:
376
391
            return os.path.abspath(self.module.__path__[0])
377
392
        elif getattr(self.module, '__file__', None) is not None:
378
 
            return os.path.abspath(self.module.__file__)
 
393
            path = os.path.abspath(self.module.__file__)
 
394
            if path[-4:] in ('.pyc', '.pyo'):
 
395
                pypath = path[:-4] + '.py'
 
396
                if os.path.isfile(pypath):
 
397
                    path = pypath
 
398
            return path
379
399
        else:
380
400
            return repr(self.module)
381
401