-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
100 lines (86 loc) · 3.35 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
## SmartRPyC setup.py
import os
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
## Import version without tainting sys.modules
version = __import__('smartrpyc').__version__
if 'smartrpyc' in sys.modules:
del sys.modules['smartrpyc']
install_requires = [
'distribute',
'pyzmq',
'msgpack-python',
]
extra = {}
if sys.version_info >= (3,):
extra['use_2to3'] = True
#extra['convert_2to3_doctests'] = ['src/your/module/README.txt']
#extra['use_2to3_fixers'] = ['your.fixers']
class PyTest(TestCommand):
test_package_name = 'smartrpyc'
def finalize_options(self):
TestCommand.finalize_options(self)
_test_args = [
'--verbose',
'--ignore=build',
'--pep8',
]
extra_args = os.environ.get('PYTEST_EXTRA_ARGS')
if extra_args is not None:
_test_args.extend(extra_args.split())
self.test_args = _test_args
self.test_suite = True
def run_tests(self):
import pytest
from pkg_resources import normalize_path, _namespace_packages
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
if sys.version_info >= (3,) and \
getattr(self.distribution, 'use_2to3', False):
#module = self.test_args[-1].split('.')[0]
module = self.test_package_name
if module in _namespace_packages:
del_modules = []
if module in sys.modules:
del_modules.append(module)
module += '.'
for name in sys.modules:
if name.startswith(module):
del_modules.append(name)
map(sys.modules.__delitem__, del_modules)
## Run on the build directory for 2to3-built code
## This will prevent the old 2.x code from being found
## by py.test discovery mechanism, that apparently
## ignores sys.path..
ei_cmd = self.get_finalized_command("egg_info")
## Replace the module name with normalized path
#self.test_args[-1] = normalize_path(ei_cmd.egg_base)
self.test_args.append(normalize_path(ei_cmd.egg_base))
errno = pytest.main(self.test_args)
sys.exit(errno)
setup(
name='SmartRPyC',
version=version,
packages=find_packages(),
url='http://xk0.github.io/SmartRPyC',
license='Apache License, Version 2.0, January 2004',
author='Samuele Santi - Flavio Percoco',
author_email='samuele@samuelesanti.com - flaper87@flaper87.org',
description='SmartRPyC is a ZeroMQ-based RPC library for Python',
long_description='SmartRPyC is a ZeroMQ-based RPC library for Python',
install_requires=install_requires,
tests_require=['pytest'],
test_suite='smartrpyc.tests',
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Development Status :: 4 - Beta",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Networking",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
],
package_data={'': ['README.rst', 'LICENSE']},
cmdclass={'test': PyTest},
**extra)