1

I'm trying to create an inproc hook written in Python for Hg/TortoiseHg. It supposed to parse the commit message and do custom operations on JIRA based on it. I'm trying to use http://jira.readthedocs.org/en/latest/#python-jira as jira API.

It works great when I test my script with python <myscript>.py. But I have problems installing jira api into TortoiseHg. For my current python instance I just used pip install jira. But it seems like TortoiseHg has its own python instance.

How can I install jira into TortoiseHg?

I've tried sys.path.append("myfolder"), then adding myfolder into my project and copying sources of jira module there. Then I do from client import JIRA, and looks like JIRA tries to load, but it seems that its dependency fails (I see No module named six.moves.urllib.parse error). So it doesn't seem like a way.

I have very little python experience so I might miss something obvious. Are there any other options?

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
Archeg
  • 8,364
  • 7
  • 43
  • 90

1 Answers1

0

In short: Check to make sure that you import all needed libs that are not jira.

Long Awnser: From my understanding your program works fine when running the script through python, this means that your script works. The problem that I could see happening is that you do not have the correct library's imported into TortoiseHg. If you look at the python doc there is a requirements section, look to see if you are using any of those libraries, if you are include those. I also read somewhere that the HTTP management is handled by some of pythons own built in libraries.

Fr3dBear
  • 16
  • 3
  • I know that I'm missing libraries. I'm actually missing `Jira` there. The problem is that I have no idea how to install it there. For now I solved the problem by running second instance of python (which is my python, so it runs ok), but this is not a long-term solution. – Archeg Nov 03 '15 at 17:43
  • In that case check the version of python that TortoiseHg uses, as you probably know anything below python 2.7 wont work. You probably should check your Mercurial version as well because from my understanding that also runs python. **Also check this link out and see if it works for you:** http://stackoverflow.com/questions/13685159/make-tortoisehg-use-my-python-installation – Fr3dBear Nov 03 '15 at 18:07
  • I'm using `TurtoiseHg` that has both `hg` and `python 2.7` embedded. I have no idea why did they do this, but they did. That's where the problem is coming from. I've tried solutions from the answer you provided, unfortunately it doesn't work. Putting `sys.path.append` to the local Python libraries folder is a nice idea, but for some reason it keeps complaining that it misses `utils` library, which I am sure I have – Archeg Nov 04 '15 at 10:23
  • Overall I starting to feel like my idea with running local python as separate process and then piping output back is the only workable solution – Archeg Nov 04 '15 at 10:25
  • When you use `sys.path.append` which location are you pointing too? Are you pointing to your pip install in your python `Lib/site-packages` folder or the `jira-master/jira`? Also if you know that TurtoiseHg is using `python 2.7` you might want to try running your py script with the same version externally, as your script might run in 3.5 but not in 2.7. – Fr3dBear Nov 04 '15 at 13:54
  • I wrote three `sys.path.append`, pointing to `Anaconda` (I'm using Py27 build from anaconda), `Anaconda\lib` and `Anaconda\lib\site-packages`. Both Hg and Anaconda have Py27. I've also tried to point it to the sources of jira, but I have to resolve it's dependencies manually which makes it very hard – Archeg Nov 04 '15 at 14:23