-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
84 lines (70 loc) · 2.27 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
from setuptools import Extension, setup, find_packages
from setuptools.command.build_ext import build_ext as _build_ext
from warnings import warn
import os.path
import shutil
from Cython.Build import cythonize
about = {}
with open("src/fzy/__about__.py", "r") as f:
exec(f.read(), about)
VERSION = about["__version__"]
FZY_VERSION = "1.0" # TODO Parse from Makefile?
include_path = ["src/fzy/"]
extensions = [
Extension(
"fzy.choices",
["src/fzy/choices.pyx"],
define_macros=[("VERSION", '"{}"'.format(FZY_VERSION))],
extra_compile_args=["-std=c99"],
),
Extension(
"fzy.match",
["src/fzy/match.pyx"],
define_macros=[("VERSION", '"{}"'.format(FZY_VERSION))],
extra_compile_args=["-std=c99"],
),
]
def copy_fzy_config(fzy_root):
# TODO Parse from Makefile?
config_src = os.path.join(fzy_root, "src/config.def.h")
config_dest = os.path.join(fzy_root, "config.h")
if not os.path.exists(config_dest):
try:
shutil.copyfile(config_src, config_dest)
except FileNotFoundError:
warn(
'fzy config definition ("{}") was not found. '.format(config_src)
+ "Ensure that the git submodules are initialized."
)
except OSError:
pass
class build_ext(_build_ext):
def run(self):
setup_py_root = os.path.dirname(os.path.abspath(__file__))
copy_fzy_config(os.path.join(setup_py_root, "fzy"))
super().run()
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="fzypy",
version=VERSION,
author="Frank Yang",
author_email="[email protected]",
description="A fuzzy finder in Python based on fzy",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/puilp0502/fzypy",
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
],
package_dir={"": "src"},
packages=find_packages(where="src"),
cmdclass={
"build_ext": build_ext,
},
ext_modules=cythonize(extensions, include_path=include_path),
python_requires=">=3.5",
)