Question

I regularly use setvirtualenvproject /path/to/my/project/ to set the root/base directory of my virtual env. This is useful when switching to a virtual env using workon myenv.

I was wondering though, if this path is available anywhere else?

In my case, I want to run a pre-push hook in git, and need to get the full path to some of my files. e.g. something like this in my pre-push hook: do_something $VIRTUALENV_PROJECT/my/important/file.txt

Is there any way I can retrieve this 'virtualenvproject' info, or where is it stored?

I've tried looking in env, the .virtualenvs dir and every other place I can think of, but I just can't find where the info's stored.

Was it helpful?

Solution

OK, seems like there were no quick takers... I ended up looking at the virtualenvwrapper.sh source, which shows that the path is dumped into $venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME.

A simple echo $VIRTUALENVWRAPPER_PROJECT_FILENAME will show you the name for your project settings (default is .project)
The fact that it's hidden is what was killing me.

So now I know this, I can do a simple:

cat $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME to get the setting. Simple!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top