Wednesday, June 13, 2012

Use requirements.txt to work on virtualenv

EDIT:

Make sure you perform all pip installs WITHOUT sudo to make sure they are isolated to the virtualenv.
Also, manually pip installing each requirement works fine for now.
Will update this with an automated method later..

#DEPRECATED
So it turns out that using pip in a virtualenv actually looks into the /usr/lib/python (ie. the host's directory) for prior installation..

For a fully isolated virutalenv, pip doesn't work right..

easy_install does though..

however easy_install is not compatible with requirements.txt generated by pip...
[Here's a requirements.txt dated 06/12/2012]

so use this script to get it done:
http://metak4ml.blogspot.com/2009/08/easyinstall-read-pip-requirementstxt.html

import os

f = open("requirements.txt")
reqs = f.read().split("\n")

for req in reqs:
    # ignore comments or pip options
    if req.startswith('--') or req.startswith('#'):
        continue
    # ignore blank lines
    if len(req) > 0:
        os.system("easy_install %s" % req)


works like a charm..

No comments:

Post a Comment

Popular Posts