using python libs and mercurial from virtualenv

Hi,

I'm using sourcetree and like it alot, however I now have to use a precomit hook from a python lib like

[hooks]
precommit=python:myhookslib.hghooks.precommit

This worked on my other computer, now however this lib is installed in a virtualenv. I've choosen the mercurial lib installed in this virtualenv, but it doesn't seems like the default python environment is started. Is there any way for me to specify what python environment sourcetree should use, like a global variable or even better if I could specify it for each repository.

4 answers

1 accepted

You can alter the script in

~/Library/Application\ Support/SourceTree/userhg_local/hg_local

In that file you alter the shebang from

#!/usr/bin/env python

which in general is the correct way to do it, to

#!/path/to/my/virtualenv/bin/python

I found that I could alter the script in ~/Library/Application Support/SourceTree/userhg_local/hg_local to start with

#!/path/to/my/virtualenv/bin/python

Although this resolvs my issue for now, I don't know what will happen after an update. Is there a better way to do it?

SourceTree will just use whatever is your default system Python, so if you made the virtualenv version the one that's used by defualt that might work. Unfrotunately to set this across OS X apps rather than the terminal you have to edit /etc/paths rather than just set PATH.

Ok, but the reason for having a virtualenv is to minimize the changes I do to the system. The problem is solved for me, but it would be nice to be able to specify wich python binary that should be used, that wold allow for use with virtualenvs

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

421 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you