-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
95 lines (86 loc) · 2.3 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
from setuptools import Extension, setup
import glob
import numpy as np
import os
import re
import pybind11
def get_version_string():
"""Extracts version number from source code."""
pattern = 'const std::string PROJECT_VERSION = "(.*)";'
with open("src/nnd.h", "r") as f:
code = f.read()
result = re.search(pattern, code).group(1)
return result
include_dirs = [
pybind11.get_include(),
np.get_include(),
]
# Get the value of the NND_DEBUG environment variable
debug = os.getenv("NND_DEBUG") == "1"
# Set the compiler flags based on the debug flag
if debug:
print("\n*** Debugging compiler flags are used. ***\n")
compile_args = [
"-O0",
"-Wall",
"-Wextra",
"-fno-stack-protector",
"-g",
"-pg",
]
else:
compile_args = [
"-DALL_METRICS",
"-Ofast",
"-flto",
"-fno-math-errno",
"-fopenmp",
"-march=native",
"-mtune=native",
]
module = Extension(
name="nndescent",
sources=glob.glob("pybindings/*.cpp") + glob.glob("src/*.cpp"),
include_dirs=include_dirs,
extra_compile_args=compile_args,
extra_link_args=["-fopenmp"],
language="c++",
)
with open("README.md", "r") as f:
long_description = f.read()
setup(
name="nndescent",
version=get_version_string(),
description="C++ extension implementing nearest neighbour descent",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=[
"numpy",
],
extras_require={
"full": [
"h5py",
"matplotlib",
"pynndescent",
"scipy",
"seaborn",
"sklearn",
],
},
ext_modules=[module],
keywords="nearest neighbor, knn, ANN",
license="BSD 2-Clause License",
author="Jon Brugger",
url="https://github.com/brj0/nndescent",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
],
)