|
4 | 4 | # LICENSE file in the root directory of this source tree. |
5 | 5 |
|
6 | 6 | from __future__ import print_function |
7 | | -from setuptools import setup, find_packages |
| 7 | + |
8 | 8 | import os |
9 | | -import shutil |
10 | 9 | import platform |
| 10 | +import shutil |
| 11 | + |
| 12 | +from setuptools import find_packages, setup |
11 | 13 |
|
12 | 14 | # make the faiss python package dir |
13 | 15 | shutil.rmtree("faiss", ignore_errors=True) |
|
20 | 22 | shutil.copyfile("extra_wrappers.py", "faiss/extra_wrappers.py") |
21 | 23 | shutil.copyfile("array_conversions.py", "faiss/array_conversions.py") |
22 | 24 |
|
23 | | -ext = ".pyd" if platform.system() == 'Windows' else ".so" |
24 | | -prefix = "Release/" * (platform.system() == 'Windows') |
| 25 | +ext = ".pyd" if platform.system() == "Windows" else ".so" |
| 26 | +prefix = "Release/" * (platform.system() == "Windows") |
25 | 27 |
|
26 | 28 | swigfaiss_generic_lib = f"{prefix}_swigfaiss{ext}" |
27 | 29 | swigfaiss_avx2_lib = f"{prefix}_swigfaiss_avx2{ext}" |
28 | 30 | swigfaiss_avx512_lib = f"{prefix}_swigfaiss_avx512{ext}" |
29 | 31 | callbacks_lib = f"{prefix}libfaiss_python_callbacks{ext}" |
30 | 32 | swigfaiss_sve_lib = f"{prefix}_swigfaiss_sve{ext}" |
| 33 | +faiss_example_external_module_lib = f"{prefix}_faiss_example_external_module{ext}" |
31 | 34 |
|
32 | 35 | found_swigfaiss_generic = os.path.exists(swigfaiss_generic_lib) |
33 | 36 | found_swigfaiss_avx2 = os.path.exists(swigfaiss_avx2_lib) |
34 | 37 | found_swigfaiss_avx512 = os.path.exists(swigfaiss_avx512_lib) |
35 | 38 | found_callbacks = os.path.exists(callbacks_lib) |
36 | 39 | found_swigfaiss_sve = os.path.exists(swigfaiss_sve_lib) |
| 40 | +found_faiss_example_external_module_lib = os.path.exists( |
| 41 | + faiss_example_external_module_lib |
| 42 | +) |
37 | 43 |
|
38 | | -assert (found_swigfaiss_generic or found_swigfaiss_avx2 or found_swigfaiss_avx512 or found_swigfaiss_sve), \ |
39 | | - f"Could not find {swigfaiss_generic_lib} or " \ |
40 | | - f"{swigfaiss_avx2_lib} or {swigfaiss_avx512_lib} or {swigfaiss_sve_lib}. " \ |
| 44 | +assert ( |
| 45 | + found_swigfaiss_generic or found_swigfaiss_avx2 or found_swigfaiss_avx512 or found_swigfaiss_sve or found_faiss_example_external_module_lib |
| 46 | +), ( |
| 47 | + f"Could not find {swigfaiss_generic_lib} or " |
| 48 | + f"{swigfaiss_avx2_lib} or {swigfaiss_avx512_lib} or {swigfaiss_sve_lib} or {faiss_example_external_module_lib}. " |
41 | 49 | f"Faiss may not be compiled yet." |
| 50 | +) |
42 | 51 |
|
43 | 52 | if found_swigfaiss_generic: |
44 | 53 | print(f"Copying {swigfaiss_generic_lib}") |
|
64 | 73 | shutil.copyfile("swigfaiss_sve.py", "faiss/swigfaiss_sve.py") |
65 | 74 | shutil.copyfile(swigfaiss_sve_lib, f"faiss/_swigfaiss_sve{ext}") |
66 | 75 |
|
67 | | -long_description=""" |
| 76 | +if found_faiss_example_external_module_lib: |
| 77 | + print(f"Copying {faiss_example_external_module_lib}") |
| 78 | + shutil.copyfile( |
| 79 | + "faiss_example_external_module.py", "faiss/faiss_example_external_module.py" |
| 80 | + ) |
| 81 | + shutil.copyfile( |
| 82 | + faiss_example_external_module_lib, |
| 83 | + f"faiss/_faiss_example_external_module{ext}", |
| 84 | + ) |
| 85 | + |
| 86 | +long_description = """ |
68 | 87 | Faiss is a library for efficient similarity search and clustering of dense |
69 | 88 | vectors. It contains algorithms that search in sets of vectors of any size, |
70 | 89 | up to ones that possibly do not fit in RAM. It also contains supporting |
|
73 | 92 | are implemented on the GPU. It is developed by Facebook AI Research. |
74 | 93 | """ |
75 | 94 | setup( |
76 | | - name='faiss', |
77 | | - version='1.9.0', |
78 | | - description='A library for efficient similarity search and clustering of dense vectors', |
| 95 | + name="faiss", |
| 96 | + version="1.9.0", |
| 97 | + description="A library for efficient similarity search and clustering of dense vectors", |
79 | 98 | long_description=long_description, |
80 | | - url='https://github.com/facebookresearch/faiss', |
81 | | - author='Matthijs Douze, Jeff Johnson, Herve Jegou, Lucas Hosseini', |
82 | | - |
83 | | - license='MIT', |
84 | | - keywords='search nearest neighbors', |
85 | | - |
86 | | - install_requires=['numpy', 'packaging'], |
87 | | - packages=['faiss', 'faiss.contrib', 'faiss.contrib.torch'], |
| 99 | + url="https://github.com/facebookresearch/faiss", |
| 100 | + author="Matthijs Douze, Jeff Johnson, Herve Jegou, Lucas Hosseini", |
| 101 | + |
| 102 | + license="MIT", |
| 103 | + keywords="search nearest neighbors", |
| 104 | + install_requires=["numpy", "packaging"], |
| 105 | + packages=["faiss", "faiss.contrib", "faiss.contrib.torch"], |
88 | 106 | package_data={ |
89 | | - 'faiss': ['*.so', '*.pyd'], |
| 107 | + "faiss": ["*.so", "*.pyd"], |
90 | 108 | }, |
91 | 109 | zip_safe=False, |
92 | 110 | ) |
0 commit comments