On Thu, Jan 14, 2010 at 8:47 PM, Greg Ward <g...@gerg.ca> wrote:
> I have written various custom hooks and extensions to use with
> Mercurial.  They all live in a common package, ims.hg (ims being the
> company name).  This works great with command-line hg: I just
> configure things like
>
>  [extensions]
>  ims.hg.ignore =
>
>  [hooks]
>  precommit.ims         = python:ims.hg.hooks.ims_precommit
>  pretxncommit.ims      = python:ims.hg.hooks.ims_pretxncommit
>
> and it doesn't matter where the .py files are: they are in Python's search 
> path.
>
> But that all breaks down with TortoiseHg: different Python, different
> search path, no ims.hg package.  I *could* workaround it to a certain
> extent like this:
>
>  [extensions]
>  ims.hg.ignore = c:\Python25\lib\site-packages\ims\hg\ignore.py
>
> but 1) that means we can't have consistent configuration in all of our
> working repositories, and 2) it doesn't do anything for dependencies
> on third-party modules.  E.g. one of my custom extensions imports
> MySQLdb... and that fails again because TortoiseHg has its own Python.
>
> Is there a good solution for this?  I found tried setting
> PYTHONPATH=C:\Python25\Lib\site-packages, but it seems that py2exe
> prevents this from working.  I found the extremely useful Mercurial
> builds at http://bitbucket.org/tortoisehg/thg-winbuild/downloads/, but
> that doesn't seem to include a TortoiseHg build that uses my
> already-installed Python.  Or am I missing something?  Do I need to
> install the GTK libs and then build TortoiseHg myself?
>
> Suggestions?  Thanks --

This FAQ entry is probably helpful:

http://bitbucket.org/tortoisehg/stable/wiki/FAQ#where-do-tortoisehg-extensions-look-for-external-python-modules-on-windows

The gist is to make an extension which is loaded before any of the
others that adds your python modules to sys.path.  I don't know if
anyone has done it to your level of complexity, but there's no reason
it couldn't work.

Something like:

[extensions]
loadims = C:\path\to\loadims.py

== loadims.py ==
sys.path.append(r'c:\Python25\lib\site-packages\')
import ims

The py2exe packaging does indeed ignore PYTHONPATH and limits the
initial sys.path to just be the library.zip file, so you have to use
tricks like the above to add directories to sys.path.

--
Steve Borho

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Tortoisehg-discuss mailing list
Tortoisehg-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-discuss

Reply via email to