#!/usr/bin/env python

import os
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as testcommand

version = "0.2.10"

if sys.argv[-1] == 'publish':
    os.system('python setup.py sdist upload')
    os.system('python setup.py bdist_wheel upload')
    sys.exit()

if sys.argv[-1] == 'tag':
    os.system("git tag -a %s -m 'version %s'" % (version, version))
    os.system("git push --tags")
    sys.exit()

readme = open('README.md').read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '')

requirements = []

long_description = readme + '\n\n' + history

if sys.argv[-1] == 'readme':
    print long_description
    sys.exit()


class PyTest(testcommand):
    user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]

    def __init__(self):
        super(testcommand, self).__init__()
        self.pytest_args = None
        self.test_args = None
        self.test_suite = None

    def initialize_options(self):
        testcommand.initialize_options(self)

    def finalize_options(self):
        testcommand.finalize_options(self)
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        import pytest
        errno = pytest.main(self.pytest_args)
        sys.exit(errno)

setup(
    name='python-hosts',
    version=version,
    author='Jon Hadfield',
    author_email='jon.hadfield@lessknown.co.uk',
    url='https://github.com/jonhadfield/python-hosts',
    download_url='https://github.com/jonhadfield/python-hosts/tarball/0.2.10',
    install_requires=[],
    description='A hosts file manager library written in python',
    long_description=long_description,
    packages=['python_hosts'],
    platforms='any',
    license='MIT',
    classifiers=[
        'Programming Language :: Python',
        'Development Status :: 2 - Pre-Alpha',
        'Natural Language :: English',
        'Environment :: Console',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: MIT License',
        'Operating System :: OS Independent',
        'Topic :: System :: Operating System',
        'Topic :: System :: Networking',
    ],
    keywords=(
        'hosts, python, network'
    ),
    cmdclass={'test': PyTest},
    test_suite='tests',
    tests_require=['pytest']
)

@@ -69,23 +69,8 @@
 etup
-, find_packages
 %0Afro
@@ -114,21 +114,20 @@
  as 
-testc
+TestC
 ommand%0A
-%0A
 vers
@@ -682,21 +682,21 @@
  PyTest(
-testc
+TestC
 ommand):
@@ -784,170 +784,54 @@
 def 
-__
 init
-__(self):%0A        super(testcommand, self).__init__()%0A        self.pytest_args = None%0A        self.test_args = None%0A        self.test_suite = None%0A%0A    def 
+ialize_options(self):%0A        TestCommand.
 init
@@ -842,33 +842,32 @@
 ze_options(self)
-:
 %0A        testcom
@@ -863,44 +863,29 @@
     
-testcommand.initialize_options(self)
+self.pytest_args = %5B%5D
 %0A%0A  
@@ -926,13 +926,13 @@
     
-testc
+TestC
 omma

fix local test runs.