"""
pip-tools keeps your pinned dependencies fresh.
"""
import sys
from setuptools import setup


setup(
    name='pip-tools',
    version='0.2',
    url='https://github.com/nvie/pip-tools/',
    license='BSD',
    author='Vincent Driessen',
    author_email='vincent@3rdcloud.com',
    description=__doc__,
    #packages=[],
    scripts=['bin/pip-review', 'bin/pip-dump'],
    #include_package_data=True,
    zip_safe=False,
    platforms='any',
    #install_requires=[],
    classifiers=[
        # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers
        #'Development Status :: 1 - Planning',
        #'Development Status :: 2 - Pre-Alpha',
        #'Development Status :: 3 - Alpha',
        'Development Status :: 4 - Beta',
        #'Development Status :: 5 - Production/Stable',
        #'Development Status :: 6 - Mature',
        #'Development Status :: 7 - Inactive',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent',
        'Topic :: System :: Systems Administration',
    ]
)

setup.py
"""
pip-tools keeps your pinned dependencies fresh.
"""
import sys
from setuptools import setup


setup(
    name='pip-tools',
    version='0.2',
    url='https://github.com/nvie/pip-tools/',
    license='BSD',
    author='Vincent Driessen',
    author_email='vincent@3rdcloud.com',
    description=__doc__,
    #packages=[],
    scripts=['bin/pip-review', 'bin/pip-dump'],
    #include_package_data=True,
    zip_safe=False,
    platforms='any',
    install_requires=['argparse==1.2.1'],  # needed for python 2.6
    classifiers=[
        # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers
        #'Development Status :: 1 - Planning',
        #'Development Status :: 2 - Pre-Alpha',
        #'Development Status :: 3 - Alpha',
        'Development Status :: 4 - Beta',
        #'Development Status :: 5 - Production/Stable',
        #'Development Status :: 6 - Mature',
        #'Development Status :: 7 - Inactive',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent',
        'Topic :: System :: Systems Administration',
    ]
)

setup.py
diff --git a/bin/pip-dump b/bin/pip-dump
index 83eb95eb5..65a40c664 100755
--- a/bin/pip-dump
+++ b/bin/pip-dump
@@ -7,10 +7,10 @@ import logging
 import tempfile
 from itertools import dropwhile, takewhile
 from functools import partial
-from subprocess import check_call as _check_call, check_output as _check_output
+from subprocess import check_call as _check_call
+import subprocess
 
 check_call = partial(_check_call, shell=True)
-check_output = partial(_check_output, shell=True)
 
 # Constants
 DEFAULT_REQUIREMENTS_FILE = 'requirements.txt'
@@ -46,8 +46,8 @@ def pip_partition(lines):
 
 
 def pip_info(filename):
-    cmd = 'pip freeze -lr {}'.format(filename)
-    raw = check_output(cmd)
+    # Use Popen instead of check_output to support Python 2.6
+    raw = subprocess.Popen(['pip', 'freeze', '-lr', filename], stdout=subprocess.PIPE).communicate()[0]
     lines = raw.split('\n')
     p = pip_partition(lines)
     return p
@@ -69,9 +69,9 @@ def rewrite(filename, lines):
 
 def dump_requirements(files):
     _, tmpfile = tempfile.mkstemp()
-    check_call('cat {} | sort -fu > {}'.format(' '.join(files), tmpfile))
+    check_call('cat %s | sort -fu > %s' % (' '.join(files), tmpfile))
     _, new = pip_info(tmpfile)
-    check_call('rm {}'.format(tmpfile))
+    check_call('rm %s' % tmpfile)
     append_lines(new, files[0])
 
     for filename in files:
diff --git a/bin/pip-review b/bin/pip-review
index 460651f25..773d70b40 100755
--- a/bin/pip-review
+++ b/bin/pip-review
@@ -57,7 +57,10 @@ def get_latest_versions(pkg_names):
 
 
 def get_installed_pkgs():
-    for line in subprocess.check_output(['pip', 'freeze']).split('\n'):
+    # Use Popen instead of check_output to support Python 2.6
+    output = subprocess.Popen(['pip', 'freeze'], stdout=subprocess.PIPE).communicate()[0]
+
+    for line in output.split('\n'):
         if not line or line.startswith('##'):
             continue
 
@@ -91,7 +94,7 @@ class InteractiveAsker(object):
 
         answer = ''
         while answer not in ['y', 'n', 'a', 'q']:
-            answer = raw_input('{} [Y]es, [N]o, [A]ll, [Q]uit '.format(prompt))
+            answer = raw_input('%s [Y]es, [N]o, [A]ll, [Q]uit ' % prompt)
             answer = answer.strip().lower()
 
         if answer in ['q', 'a']:
@@ -103,7 +106,7 @@ ask_to_install = partial(InteractiveAsker().ask, prompt='Upgrade now?')
 
 
 def update_pkg(pkg, version):
-    os.system('pip install {}=={}'.format(pkg, version))
+    os.system('pip install %s==%s' % (pkg, version))
 
 
 def confirm(question):
@@ -134,7 +137,7 @@ def main():
     all_ok = True
     for pkg, installed_version, editable in installed:
         if editable and not args.editables:
-            logging.debug('Skipping -e {}=={}'.format(pkg, installed_version))
+            logging.debug('Skipping -e %s==%s' % (pkg, installed_version))
             all_ok = False
             continue
 
diff --git a/setup.py b/setup.py
index 5060b2a90..f9786f043 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@
     #include_package_data=True,
     zip_safe=False,
     platforms='any',
-    #install_requires=[],
+    install_requires=['argparse==1.2.1'],  # needed for python 2.6
     classifiers=[
         # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers
         #'Development Status :: 1 - Planning',
diff --git a/tests/dump-to-multiple-req-files.t b/tests/dump-to-multiple-req-files.t
index 5af80efd1..0f0ee22f6 100644
--- a/tests/dump-to-multiple-req-files.t
+++ b/tests/dump-to-multiple-req-files.t
@@ -8,9 +8,13 @@ Setup:
 
   $ echo "times" > requirements.txt
   $ pip install -r requirements.txt >/dev/null 2>&1
-  $ echo "Flask\nWerkzeug\nJinja2" > more-requirements.txt
+  $ echo "Flask\nWerkzeug\nJinja2\n" > more-requirements.txt
   $ pip install -r more-requirements.txt >/dev/null 2>&1
 
+Install argparse so pip-dump works in Python 2.6
+
+  $ pip install argparse >/dev/null 2>&1
+
 Next, let's see what pip-dump does:
 
   $ pip-dump
@@ -18,6 +22,7 @@ Next, let's see what pip-dump does:
 It should've updated requirements.txt with pinned versions of all requirements:
 
   $ cat requirements.txt
+  argparse==* (glob)
   python-dateutil==* (glob)
   pytz==* (glob)
   six==* (glob)
diff --git a/tests/dump.t b/tests/dump.t
index 499e0b962..bdea2d111 100644
--- a/tests/dump.t
+++ b/tests/dump.t
@@ -9,6 +9,10 @@ Setup:
   $ echo "times" > requirements.txt
   $ pip install -r requirements.txt >/dev/null 2>&1
 
+Install argparse so pip-dump works in Python 2.6
+
+  $ pip install argparse >/dev/null 2>&1
+
 Next, let's see what pip-dump does:
 
   $ pip-dump
@@ -16,6 +20,7 @@ Next, let's see what pip-dump does:
 It should've updated requirements.txt with pinned versions of all requirements:
 
   $ cat requirements.txt
+  argparse==* (glob)
   python-dateutil==* (glob)
   pytz==* (glob)
   six==* (glob)
diff --git a/tests/review.t b/tests/review.t
index 815b5541c..cf960b65a 100644
--- a/tests/review.t
+++ b/tests/review.t
@@ -12,7 +12,11 @@ Also install library, which caused warning message:
 
   $ pip install http://www.effbot.org/media/downloads/cElementTree-1.0.5-20051216.tar.gz >/dev/null 2>&1
 
-Next, let's see what pip-dump does:
+Install argparse so pip-review works in Python 2.6
+
+  $ pip install argparse >/dev/null 2>&1
+
+Next, let's see what pip-review does:
 
   $ pip-review
   Warning: cannot find svn location for cElementTree==1.0.5-20051216

Support Python versions lower than 2.7, too

