-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
89 lines (75 loc) · 2.63 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
import os
import sys
from subprocess import Popen, PIPE
from setuptools import setup, find_packages, Extension
from setuptools.command.test import test as TestCommand
def pkgconfig(*packages, **kw):
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
cmd = "pkg-config --libs --cflags %s" % ' '.join(packages)
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE)
res = p.stdout.read().decode('utf-8')
p.wait()
for token in res.split():
kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
return kw
def gen_pytest_class(args):
class PyTest(TestCommand):
def initialize_options(self):
TestCommand.initialize_options(self)
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_suite = True
self.test_args = args
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
return PyTest
version = '0.5.2'
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
tests_require = [
'pytest',
]
if sys.version_info < (2, 7):
tests_require.append('unittest2')
if sys.version_info < (3, 3):
tests_require.append('mock')
setup(name='pyroonga',
version=version,
description="Python interface for groonga",
long_description=README + '\n\n' + CHANGES,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Indexing/Search',
'Topic :: Software Development :: Libraries'
],
keywords='groonga fulltext search engine',
author='Naoya Inada',
author_email='[email protected]',
url='https://github.com/naoina/pyroonga',
license='MIT',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[
# -*- Extra requirements: -*-
],
tests_require=tests_require,
ext_modules=[Extension(
'_groonga',
sources=['_groonga.c'],
define_macros=[],
**pkgconfig('groonga')
)],
cmdclass={
'test': gen_pytest_class(['pyroonga/tests/unit']),
'testfunctional': gen_pytest_class(['pyroonga/tests/functional']),
'testall': gen_pytest_class(['pyroonga/tests']),
},
)