How to install Python modules needed by plugins?
Eli Zaretskii
eliz at gnu.org
Wed Mar 9 13:19:27 UTC 2011
> Date: Wed, 09 Mar 2011 12:48:10 +0200
> From: Alexander Belchenko <bialix at ukr.net>
> CC: bazaar at lists.canonical.com
>
> Actually we can mangle sys.path for bzr.exe using plugin, but we need to
> put it first in the loading list, so let's name it a.py:
>
> #-----------------------------------------------------------------
> if getattr(sys, 'frozen', None) is not None:
> sys.path.append(os.path.join(os.path.dirname(sys.executable),
> 'site-packages'))
> #-----------------------------------------------------------------
>
> And after that you should be able to put extra python libs into
> C:\Program Files\Bazaar\site-packages
Here's what I actually put into my plugins/ directory:
"""Extends sys.path to include the 'site-packages' subdirectory."""
import sys
import os
if getattr(sys, 'frozen', None) is not None:
sys.path.append(os.path.join(os.path.dirname(sys.executable),
'site-packages'))
And the advantage of this over adding to library.zip is not only that
library.zip is left untouched, but also that files in site-packages
will be compiled into *.pyo, while those in library.zip won't.
Thanks again for this tip.
More information about the bazaar
mailing list