Thursday, October 2, 2014

python+virtualenv on Cygwin

I recently made Linux my platform for development, Firstly ue to the similarity with my production platform. Secondly because most open source programming tool performs optimally in Linux based system.

However, unless I replace my ageing system with a Mac, I will still need Windows OS for my small day to day works. So I have been doing most of my techical jobs on Ubuntu 12, installed ob Oracle VirtualBox.

However, I have been noticing some annoying delay, which prompted me to consider using Cygwin.

After pulling my hair a bit, I managed to figure out how to install python developement tools on Cygwin.
  1. Install Python. 
  2. Download and unzip pip. 
  3. Install by going into the expanded directory and running python setup.py in a command prompt.
  4. Set the %PYTHONHOME% system variable to the python base directory, (i.e. C:\Python27\) and adding the python base directory and script directory (i.e. C:\Python27\Scripts) to your %PATH% system variable.
  5. Install Cygwin WITHOUT Python. The previous step tells Cygwin to use the Windows binary.
  6. Install Cygwin-Virtualenvwrapper using pip install https://bitbucket.org/cliffxuan/virtualenvwrapper-for-cygwin-windows-python/get/tip.tar.gz
  7. Install virtualenvwrapper-win using pip install virtualenvwrapper-win
  8. Make a symlink between Cygwin's virtualenvhome directory and Windows's using ln -s /cygdrive/c/Users/<USER>/Envs/ ~/.virtualenvs
  9. Add the following to Cygwin's .bashrc file: 
  10. export VIRTUALENVWRAPPER_PYTHON="/cygdrive/c/Python27/python.exe"
    export VIRTUALENVWRAPPER_VIRTUALENV="/cygdrive/c/Python27/Scripts/virtualenv.exe"
    source virtualenvwrapper.sh
     
  11. Go to C:\User\<username>\Env (or other %VIRTUALENV_HOME% location) and use virtualenv to start a new environment. Doing this allows virtualenvwrapper-win's workon command to work.


No comments: