Wednesday, June 13, 2012

Use requirements.txt to work on virtualenv


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..

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:

import os

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

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

works like a charm..

No comments:

Post a Comment

Popular Posts