| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
import os |
| 4 |
import re |
| 5 |
import sys |
| 6 |
from setuptools import setup |
| 7 |
from setuptools.command.test import test as TestCommand |
| 8 |
|
| 9 |
HERE = os.path.dirname(os.path.realpath(__file__)) |
| 10 |
|
| 11 |
|
| 12 |
class PyTest(TestCommand): |
| 13 |
""" |
| 14 |
Run py.test with the "python setup.py test command" |
| 15 |
""" |
| 16 |
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] |
| 17 |
|
| 18 |
def initialize_options(self): |
| 19 |
TestCommand.initialize_options(self) |
| 20 |
self.pytest_args = '' |
| 21 |
|
| 22 |
def finalize_options(self): |
| 23 |
TestCommand.finalize_options(self) |
| 24 |
self.pytest_args += (' ' + self.distribution.test_suite) |
| 25 |
|
| 26 |
def run_tests(self): |
| 27 |
import pytest |
| 28 |
errno = pytest.main(self.pytest_args) |
| 29 |
sys.exit(errno) |
| 30 |
|
| 31 |
|
| 32 |
def read(*parts): |
| 33 |
with open(os.path.join(HERE, *parts)) as f: |
| 34 |
return f.read() |
| 35 |
|
| 36 |
|
| 37 |
def parse_requirements(data, exclude=()): |
| 38 |
return [line for line in data.splitlines() |
| 39 |
if line and not line.startswith("#") and line not in exclude] |
| 40 |
|
| 41 |
|
| 42 |
def version(): |
| 43 |
return re.findall(r"__version__ = \"([\d.]+)\"", |
| 44 |
read("dlmanager", "__init__.py"))[0] |
| 45 |
|
| 46 |
setup( |
| 47 |
name="dlmanager", |
| 48 |
version=version(), |
| 49 |
description="download manager library", |
| 50 |
long_description=read("README.rst"), |
| 51 |
author="Julien Pagès", |
| 52 |
author_email="[email protected]", |
| 53 |
url="http://github.com/parkouss/dlmanager", |
| 54 |
license="GPL/LGPL", |
| 55 |
install_requires=parse_requirements(read("requirements.txt")), |
| 56 |
cmdclass={'test': PyTest}, |
| 57 |
tests_require=parse_requirements(read("requirements.txt"), |
| 58 |
exclude=("-e .",)), |
| 59 |
test_suite='tests', |
| 60 |
) |