I'd like to work in my virtualenv from textmate 2, but i really have no idea on how to indicate text mate the env of python it has to use.
If anyone can help, thank you.
I'd like to work in my virtualenv from textmate 2, but i really have no idea on how to indicate text mate the env of python it has to use.
If anyone can help, thank you.
If there's a project folder associated with your virtualenv, you could add a .tm_properties
file that contains something like
TM_PYTHON = "$HOME/.virtualenvs/example/bin/python"
In fact, I might make a project template for virtualenvwrapper that does just that for all new projects.
To set it globally in TextMate 2, just add TM_PYTHON to the Variables section of the preferences. You should be able to set PYTHONPATH the same way (per-project or application-wide).
You will probably need to use a wrapper script, to first activate the virtualenv and then (within virtualenv) start the textmate2 process.
wrapper example:
#!/bin/sh
# load the virtual env
. $HOME/MY-VENV/bin/activate
# run the editor
/path/to/textmate "$@"
This article essentially shows Rob McBroom and K.-Michael Aye's answers in greater detail.
NOTE: It seems that you must disable any she-bangs (#!/usr/bin/env python
in my case) for this to work.
TM_PYTHON in the TM2 preferences for environment variables determines the Python to the preferred interpreter, but I did not find out yet, how to set the PYTHONPATH for TM2 yet.