Permalink
Browse files

Merge pull request #7 from nimbis/venv

Add -E,--environment flag for virtualenv location.
  • Loading branch information...
2 parents 7d79018 + 7d50fa1 commit c1c7921784d0315b659e0b53a2752ee5f0d202fe @dcramer committed Aug 17, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/piplint/__init__.py
View
@@ -12,7 +12,7 @@
from subprocess import Popen, PIPE
-def check_requirements(requirement_files, strict=False):
+def check_requirements(requirement_files, strict=False, venv=None):
"""
Given a list of requirements files, checks them against the installed
packages in the currentl environment. If any are missing, or do not fit
@@ -84,8 +84,10 @@ def valid_version(version, compare, r_version):
frozen_reqs = []
unknown_reqs = set()
listed_reqs = []
-
- freeze = Popen(['pip freeze'], stdout=PIPE, shell=True)
+ args = 'pip freeze'
+ if venv is not None:
+ args = venv + "/bin/" + args
+ freeze = Popen([args], stdout=PIPE, shell=True)
for line in freeze.communicate()[0].splitlines():
line = line.strip()
if not is_requirements_line(line):
@@ -139,6 +141,8 @@ def main():
import optparse
parser = optparse.OptionParser()
parser.add_option("--strict", dest="strict", action='store_true', default=False)
+ parser.add_option("-E", "--environment", dest="venv", metavar="DIR",
+ default=None, help="virtualenv environment to check against")
(options, file_list) = parser.parse_args()
if not file_list:
print "Usage: piplint <requirements.txt>"

0 comments on commit c1c7921

Please sign in to comment.