-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
67 lines (51 loc) · 1.48 KB
/
setup.py
File metadata and controls
67 lines (51 loc) · 1.48 KB
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
"""
setup.py
use with pyproject.toml
"""
# !/usr/bin/env python
# -*- coding:utf8 -*-
#
# created by skiloop@gmail.com 2018/7/27
#
import platform
import sys
try:
from setuptools import setup, Extension
except ImportError:
from distutils.extension import Extension
from distutils.core import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
def scan_argv(argv, feat):
for i in range(len(argv)):
arg = argv[i]
if arg == feat:
del argv[i]
return True
return False
# the c++ extension module
libraries = []
extra_compile_flags = [] if platform.system() == 'Windows' else ['-std=c++11']
extra_link_flags = []
sources = ["src/py_simhash.cpp", "src/SimHashBase.cpp"]
def run_setup():
extension_mod = Pybind11Extension(
"pysimhash", sources,
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_flags,
libraries=libraries)
setup(ext_modules=[extension_mod], cmdclass={"build_ext": build_ext})
help_text = """
"""
def strip_local_options(argv):
options = ["--help", "-h", "--debug"]
for option in options:
scan_argv(argv, option)
if __name__ == "__main__":
if "--help" in sys.argv or "-h" in sys.argv:
print(help_text)
strip_local_options(sys.argv)
run_setup()
sys.exit()
if scan_argv(sys.argv, "--debug"):
extra_compile_flags.append("/DDEBUG" if platform.system() == 'Windows' else '-DDEBUG')
run_setup()