forked from douban/libmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
84 lines (71 loc) · 2.68 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
import os
import re
import sys
from glob import glob
from setuptools import setup, Extension
from setuptools.command.test import test as TestCommand
if sys.version[0] == '2':
# setuptools DWIM monkey-patch madness: http://dou.bz/37m3XL
if 'setuptools.extension' in sys.modules:
m = sys.modules['setuptools.extension']
m.Extension.__dict__ = m._Extension.__dict__
sources = (glob("src/*.cpp") +
["libmc/_client.pyx"])
include_dirs = ["include"]
COMPILER_FLAGS = ["-fno-strict-aliasing", "-fno-exceptions", "-fno-rtti",
"-Wall", "-DMC_USE_SMALL_VECTOR", "-O3", "-DNDEBUG"]
def find_version(*file_paths):
with open(os.path.join(*file_paths)) as fhandler:
version_file = fhandler.read()
version_match = re.search(r"^__VERSION__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ['tests']
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 pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
setup(
name="libmc",
packages=["libmc"],
version=find_version("libmc", "__init__.py"),
license= "BSD License",
description="Fast and light-weight memcached client for C++/Python",
author="PAN, Myautsai",
author_email="myautsai@gmail.com",
url="https://github.com/douban/libmc",
keywords=["memcached", "memcache", "client"],
long_description=open("README.rst").read(),
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Development Status :: 5 - Production/Stable",
"Programming Language :: C++",
"Programming Language :: Python",
"Programming Language :: Python :: Implementation :: CPython",
"Operating System :: POSIX :: Linux",
"Topic :: Software Development :: Libraries"
],
# Support for the basestring type is new in Cython 0.20.
setup_requires=["setuptools_cython", "Cython >= 0.20"],
cmdclass={"test": PyTest},
ext_modules=[
Extension("libmc._client", sources, include_dirs=include_dirs,
language="c++", extra_compile_args=COMPILER_FLAGS)
],
tests_require=[
"pytest",
"future",
]
)