Sunday, August 30, 2009

easy_install read pip requirements.txt file

No way to feed PIP requirements file into easy_install, so the following snippet do the job:-


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)

No comments: