IMPROVE packaging and testing

* uses now tox (currently with no tests) on python 2.7 and 3.4
* upgraded setup.py to setuptools
This commit is contained in:
Patrick Kanzler 2015-12-30 16:58:28 +01:00
parent 6cc325b395
commit 029549aaae
3 changed files with 44 additions and 2 deletions

4
.gitignore vendored
View File

@ -7,3 +7,7 @@ $~
# temporary data # temporary data
temp temp
# packaging and testing
.tox/
*.egg-info/

View File

@ -1,6 +1,35 @@
#!/usr/bin/python #!/usr/bin/python
from distutils.core import setup import os
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
def read(fname):
"""read file from same path as setup.py"""
return open(os.path.join(os.path.dirname(__file__), fname)).read()
class Tox(TestCommand):
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import tox
import shlex
args = self.tox_args
if args:
args = shlex.split(self.tox_args)
errno = tox.cmdline(args=args)
sys.exit(errno)
setup( setup(
name='escpos', name='escpos',
@ -9,7 +38,7 @@ setup(
download_url='https://github.com/manpaz/python-escpos.git', download_url='https://github.com/manpaz/python-escpos.git',
description='Python library to manipulate ESC/POS Printers', description='Python library to manipulate ESC/POS Printers',
license='GNU GPL v3', license='GNU GPL v3',
long_description=open('README').read(), long_description=read('README'),
author='Manuel F Martinez', author='Manuel F Martinez',
author_email='manpaz@bashlinux.com', author_email='manpaz@bashlinux.com',
platforms=['linux'], platforms=['linux'],
@ -32,4 +61,6 @@ setup(
'qrcode>=4.0', 'qrcode>=4.0',
'pyserial', 'pyserial',
], ],
tests_require=['tox'],
cmdclass={'test': Tox},
) )

7
tox.ini Normal file
View File

@ -0,0 +1,7 @@
[tox]
envlist = py27, py34
[testenv]
deps = nose
coverage
# TODO: implement code coverage analysis (and of course tests at first)