-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
48 lines (44 loc) · 1.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
from __future__ import annotations
from setuptools import setup, find_packages
import yaml, os
import glob
__this_dir = os.path.dirname(__file__)
_yaml_version_file = os.path.join(__this_dir, "lires", "version.yaml")
with open(_yaml_version_file, "r", encoding='utf-8') as fp:
version_histories: dict[str, list[str]] = yaml.safe_load(fp)["version_history"]
_VERSION_HISTORIES = []
for v, h in version_histories.items():
v = v.split("-")[0].strip()
_VERSION_HISTORIES.append((v, h))
VERSION, _ = _VERSION_HISTORIES[-1]
def vectorLibExt():
from pybind11.setup_helpers import Pybind11Extension, ParallelCompile, naive_recompile
ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile, default=4).install()
source_dir = './lires/vector/c'
eigen_dir = './external/eigen'
compile_files = [ os.path.relpath(f, __this_dir) for f in glob.glob(os.path.join(source_dir, "*.cpp"), recursive=True)]
include_dirs = [source_dir, eigen_dir]
return [
Pybind11Extension(
"lires.vector.lib.impl{}".format(vector_dim),
compile_files,
define_macros=[
("FEAT_DIM", vector_dim),
("MODULE_NAME", "impl{}".format(vector_dim)),
("NDEBUG", None),
],
include_dirs=include_dirs,
cxx_std=17,
language="c++",
# add some optimization flags
extra_compile_args=["-O2", '-funroll-loops'] # '-march=native', '-mtune=native', '-fopenmp'],
)
for vector_dim in [768]
]
setup(
name="Lires",
version=VERSION,
packages=find_packages(),
include_package_data = True,
ext_modules=vectorLibExt(),
)