<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 11/08/10 11:12 PM, Alexander Belchenko wrote:
    <blockquote type="cite">Brendan Simon (eTRIX) пишет:
      <br>
      <blockquote type="cite">  I'm having problems running Trac 0.12
        with TracBzr 0.4 plugin on OS X 10.6.
        <br>
        The log file shows:
        <br>
        <br>
            2010-08-11 22:26:05,662 Trac[loader] ERROR: Skipping "bzr =
        <br>
            tracbzr.backend": (can't import "ImportError: No module
        named bzrlib")
        <br>
        <br>
        bzr is installed as /usr/local/bin/bzr
        <br>
        <br>
        It seems that Trac can not find the bzrlib module to import.
        <br>
        Where would I find this ??
        <br>
      </blockquote>
      <br>
      run `bzr version` and check output, it will point you to the right
      directory with bzrlib. Also check the Python version used by bzr.
      <br>
    </blockquote>
    OK.  The Apple provided python is 2.6.1, installed in /System and
    can be invoked with /usr/bin/python.  However, I have also installed
    2.6.5 which is placed in /Library/Frameworks/Python.framework/ and
    can be invoked with /usr/local/bin/python<br>
    <br>
    My PATH is setup to find Python 2.6.5 first, thus running tracd is
    invoked with python 2.6.5, but bzrlib is not found in that path.<br>
    <br>
    <blockquote><tt>$ /usr/bin/python2.6 -c "import sys; print
        sys.version; import bzrlib; print bzrlib"<br>
        2.6.1 (r261:67515, Feb 11 2010, 00:51:29) <br>
        [GCC 4.2.1 (Apple Inc. build 5646)]<br>
        &lt;module 'bzrlib' from
        '/Library/Python/2.6/site-packages/bzrlib/__init__.pyc'&gt;<br>
        <br>
        $ /usr/local/bin/python2.6 -c "import sys; print sys.version;
        import bzrlib; print bzrlib"<br>
        2.6.5 (r265:79359, Mar 24 2010, 01:32:55) <br>
        [GCC 4.0.1 (Apple Inc. build 5493)]<br>
        Traceback (most recent call last):<br>
          File "&lt;string&gt;", line 1, in &lt;module&gt;<br>
        ImportError: No module named bzrlib<br>
      </tt></blockquote>
    <br>
    On a side note, why Python 2.6.5 is compiled with the older gcc-4.0
    instead of the newer gcc-.4.2 is unknown to me.  Presumably the
    Python OS X packagers use older systems for compatibility with older
    OS X systems ??<br>
    <br>
    Anyway, the OS X Bazaar installer always installs in /System to use
    the Apple python.  This makes some sense, but how to use it with
    newer versions of python ??<br>
    <br>
    Is setting PYTHONPATH the way to go ??<br>
    <br>
    I <u>think</u> wxPython had issues with systems installs of python
    versus user installs ??<br>
    and I <u>think</u> they resolved that using wxredirect.pth file,
    which has the following content.<br>
    <br>
    <blockquote><tt>import site;
site.addsitedir('/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6')<br>
      </tt></blockquote>
    <br>
    Not sure if something like that could be useful for Bazaar
    installations ??<br>
    <br>
    <br>
    <blockquote type="cite">
      <blockquote type="cite">Where does the OS X Bazaar (2.1.2)
        installer put the bzrlib module (if anywhere) ??
        <br>
        <br>
        I thought it might be in
        /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.5/site-packages/
        but that does not appear to be the case.
        <br>
        <br>
        Do I have to specify some path in the trac.ini file so that Trac
        can find bzrlib ??
        <br>
      </blockquote>
      <br>
      You should ensure your Trac installation runs the same Python
      version as bzr, and if needed you can add path to the directory
      where bzrlib located to PYTHONPATH environment variable. Then
      check with command:
      <br>
      <br>
      python -c "import bzrlib; print bzrlib"
      <br>
    </blockquote>
    <br>
    "bzr --version" shows me that bzrlib is installed in:
    /Library/Python/2.6/site-packages/bzrlib<br>
    <br>
    I used a startup script for the tracd server, set/exported
    PYTHONPATH to "/Library/Python/2.6/site-packages" and now it works
    :)<br>
    <br>
    <blockquote><tt>#!/bin/bash</tt><br>
      <tt><br>
        BZRLIB_DIR=$(bzr --version | grep bzrlib | cut -d ' ' -f 4)</tt><br>
      <tt><br>
        VER=$(echo ${BZRLIB_DIR} | grep -o '[0-9]\.[0-9]')</tt><br>
      <tt><br>
        PYTHON="python${VER}"</tt><br>
      <tt><br>
        PYTHONPATH=$(dirname ${BZRLIB_DIR})</tt><br>
      <tt>export PYTHONPATH</tt><br>
      <tt><br>
TRACD=/Library/Frameworks/Python.framework/Versions/${VER}/bin/tracd</tt><br>
      <tt><br>
        PORT=8000</tt><br>
      <tt><br>
        <br>
AUTH="myproject,/Users/brendan/trac/myproject/conf/users.htdigest,etrix.com.au"</tt><br>
      <tt><br>
        ENV=/Users/brendan/trac/myproject</tt><br>
      <tt><br>
        ${PYTHON} ${TRACD} --port ${PORT} --auth=${AUTH} ${ENV}</tt><br>
    </blockquote>
    <br>
    Cheers, Brendan.<br>
    <br>
  </body>
</html>