From 4b5a307dd29e4c3d56ac570b89d77c21cb718295 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Sun, 17 Dec 2017 17:55:29 +0800 Subject: [PATCH] fix install error on Windows --- MANIFEST.in | 1 + pydu/__init__.py | 2 +- requirements-dev.txt | 5 +++-- setup.cfg | 7 +++++-- setup.py | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..450205c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include requirements-dev.txt \ No newline at end of file diff --git a/pydu/__init__.py b/pydu/__init__.py index af707f7..a893506 100644 --- a/pydu/__init__.py +++ b/pydu/__init__.py @@ -2,7 +2,7 @@ Useful data structures, utils for Python. """ -__version__ = '0.1.0' +__version__ = '0.1.1' # Set logging handler to avoid "No handler found" warnings. diff --git a/requirements-dev.txt b/requirements-dev.txt index 1f81207..94a7a0d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ -pytest +pytest>=2.8.0 +pytest-xdist coveralls -HTTPretty==0.8.14 \ No newline at end of file +HTTPretty==0.8.14 diff --git a/setup.cfg b/setup.cfg index b7e4789..2e9053c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,5 @@ -[aliases] -test=pytest +[bdist_wheel] +universal = 1 + +[metadata] +license_file = LICENSE.txt diff --git a/setup.py b/setup.py index 4271c3e..2436407 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,37 @@ +import sys from pydu import __version__ from setuptools import setup, find_packages +from setuptools.command.test import test as TestCommand + + +class PyTest(TestCommand): + user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")] + + def initialize_options(self): + TestCommand.initialize_options(self) + try: + from multiprocessing import cpu_count + self.pytest_args = ['-n', str(cpu_count()), '--boxed'] + except (ImportError, NotImplementedError): + self.pytest_args = ['-n', '1', '--boxed'] + + 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) + + +test_requirements = [] +for line in open('requirements-dev.txt'): + requirement = line.strip() + if requirement: + test_requirements.append(requirement) setup( @@ -11,7 +43,8 @@ setup( author_email='wangbinxin001@126.com', license='MIT License', url="https://github.com/Prodesire/pydu", - setup_requires=['pytest-runner'], + cmdclass={'test': PyTest}, + tests_require=test_requirements, packages=find_packages(), classifiers=[ 'Operating System :: OS Independent',