Activate a python virtual environment using activate_this.py in a fabfile on Windows
Posted
by Rudy Lattae
on Stack Overflow
See other posts from Stack Overflow
or by Rudy Lattae
Published on 2010-04-15T08:04:01Z
Indexed on
2010/04/20
3:43 UTC
Read the original article
Hit count: 417
I have a Fabric task that needs to access the settings of my Django project.
On Windows, I'm unable to install Fabric into the project's virtualenv (issues with Paramiko + pycrypto deps). However, I am able to install Fabric in my system-wide site-packages, no problem.
I have installed Django into the project's virtualenv and I am able to use all the "> python manage.py" commands easily when I activate the virtualenv with the "VIRTUALENV\Scripts\activate.bat" script.
I have a fabric tasks file (fabfile.py) in my project that provides tasks for setup, test, deploy, etc. Some of the tasks in my fabfile need to access the settings of my django project through "from django.conf import settings".
Since the only usable Fabric install I have is in my system-wide site-packages, I need to activate the virtualenv within my fabfile so django becomes available. To do this, I use the "activate_this" module of the project's virtualenv in order to have access to the project settings and such. Using "print sys.path" before and after I execute activate_this.py, I can tell the python path changes to point to the virtualenv for the project. However, I still cannot import django.conf.settings.
I have been able to successfully do this on *nix (Ubuntu and CentOS) and in Cygwin. Do you use this setup/workflow on Windows? If so Can you help me figure out why this wont work on Windows or provide any tips and tricks to get around this issue?
Thanks and Cheers.
REF:
- http://virtualenv.openplans.org/#id9 | Using Virtualenv without bin/python
Local development environment:
- Python 2.5.4
- Virtualenv 1.4.6
- Fabric 0.9.0
- Pip 0.6.1
- Django 1.1.1
- Windows XP (SP3)
© Stack Overflow or respective owner