-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
116 lines (102 loc) · 3.65 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
import re
from setuptools import Extension, setup
from distutils.ccompiler import get_default_compiler
import os
import io
import sys
from os.path import dirname, join as pjoin
__version__ = '0.7.2'
# Edit posix platname for pypi upload error
if os.name == "posix" and any(x.startswith("bdist") for x in sys.argv) \
and not ("--plat-name" in sys.argv or "-p" in sys.argv):
if "64" in os.uname()[-1]:
from platname import get_platname_64bit
plat = get_platname_64bit()
else:
from platname import get_platname_32bit
plat = get_platname_32bit()
sys.argv.extend(["--plat-name", plat])
ext_modules = [
Extension(
'cdiffer',
sources=['src/cdiffer.cpp'],
language="c++",
include_dirs=["src"],
extra_compile_args=[
"/std:c++14" if os.name == "nt" else "-std=c++14",
# "/IC:/usr/lib/boost",
]
)]
if any("--debug" in x or "-g" in x for x in sys.argv) and get_default_compiler() == "msvc":
ext_modules = [
Extension(
'cdiffer',
sources=['src/cdiffer.cpp'],
# Reason is Debuging Error "Access violation executing location 0x00000000" when using mwArray in Visual-C++
undef_macros=["_DEBUG"],
extra_compile_args=[
# Reason https://docs.microsoft.com/ja-jp/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-160
"/GL",
"/Wall", "/wd", "4514", "/wd 4820", "/wd 5045", "/wd 4100", "/wd 4191", "/wd 4710",
# Reason unicode string crash #
"/source-charset:utf-8",
# Reason IDE warning link crash #
"/FC",
"/std:c++14",
# "/IC:/usr/lib/boost",
],
language="c++",
include_dirs=["src"]
)]
CF = """
Development Status :: 5 - Production/Stable
License :: OSI Approved :: MIT License
Programming Language :: C
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Operating System :: OS Independent
Operating System :: Microsoft :: Windows
Operating System :: MacOS
Operating System :: POSIX
"""
# Programming Language :: Python :: 2.7
# Readme read or edit
readme = pjoin(dirname(__file__), "README.md")
badge = re.compile(r'(\[!\[.*?\]\(https://.*?badge\.(?:svg|png)\?branch=([^\)]+)\)\])')
description = ""
is_change = False
with io.open(readme, encoding="utf-8") as f:
for line in f:
res = badge.search(line)
if res and __version__ not in res.group(2):
for b, k in badge.findall(line):
line = line.replace(b, b.replace(k, "v" + __version__))
is_change = True
description += line
if is_change:
with io.open(readme, "w", encoding="utf-8") as f:
f.write(description)
# for python2.7
tests = {}
if sys.version_info[:2] >= (3, 3):
tests = dict(
setup_requires=["pytest-runner"],
tests_require=["pytest", "pytest-cov", "psutil"])
setup(name="cdiffer",
version=__version__,
description="Edit distance, Similarity and 2 sequence differences printing",
long_description_content_type='text/markdown',
long_description=description,
url='https://github.com/kirin123kirin/cdiffer',
author='kirin123kirin',
ext_modules=ext_modules,
keywords=["diff", "comparison", "compare", "editdistance"],
license="MIT",
platforms=["Windows", "Linux", "Mac OS-X"],
classifiers=CF.strip().splitlines(),
**tests
)