0

I created some python hooks for Mercurial that use some external libraries (namely jira-python). In Linux, I install the packages using pip. In Windows, however, Mercurial comes with a bundled version of Python. My hooks fail when I run them because the external packages are not installed.

I want to make Mercurial / TortoiseHG use my Python installation so I can control its environment. How can I do that?

Amir Rachum
  • 76,817
  • 74
  • 166
  • 248

2 Answers2

1

You can install Mercurial package for Python:

For TortoiseHG-specific details I can suggest to inspect %TortoiseHg%\library.zip - it contains (some? all?) needed for TortoiseHG|Mercurial Python's modules, which list you can (try) to extend: "in Where is the Python path for TortoiseHG?" topic Steve Borho wrote:

TortoiseHg's entire python environment is contained within the library.zip that comes packaged with it.

What I suspect you can do is add a line or two to the top of your reviewboard extension file to add your installed python path to sys.path before trying to import simplejson

Hint for adding python path to sys.path is applicable for you too

Recommendation from Convert Extension page

you'll need to use a Mercurial installed on top of a stand-alone Python, and you may also need to do something like

set HG=python c:\Python25\Scripts\hg

to override the default Win32 binaries if you have those installed also

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
0

I have Mercurial installed through pip, and I also have TortoiseHg. My system path selects the Python version first.

I renamed C:\Program Files\TortoiseHg\hg.exe to something else, and then ran TortoiseHg. Everything still worked, but I haven't got a good way of verifying it does what you want. You can give it a shot.

moswald
  • 11,491
  • 7
  • 52
  • 78
  • Mercurial installs through pip so easily, I'd honestly prefer if TortoiseHg would ship a version *without* a bundled hg.exe. – moswald Dec 03 '12 at 16:47
  • Well, since TortoiseHg uses Library.zip for its Python libraries, my suggestion probably won't work. :/ – moswald Dec 03 '12 at 16:54