|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# |
| 3 | +# This source code is licensed under the MIT license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | + |
| 6 | +[build-system] |
| 7 | +requires = ["scikit-build-core>=0.10", "numpy>=2.0"] |
| 8 | +build-backend = "scikit_build_core.build" |
| 9 | + |
| 10 | +[project] |
| 11 | +name = "faiss-cpu" |
| 12 | +version = "1.14.0" |
| 13 | +description = "A library for efficient similarity search and clustering of dense vectors." |
| 14 | +readme = "README.md" |
| 15 | +license = "MIT" |
| 16 | +requires-python = ">=3.10" |
| 17 | +authors = [ |
| 18 | + {name = "Meta AI Research"}, |
| 19 | +] |
| 20 | +keywords = ["search", "nearest-neighbors", "clustering", "vectors", "similarity"] |
| 21 | +classifiers = [ |
| 22 | + "Development Status :: 5 - Production/Stable", |
| 23 | + "Intended Audience :: Developers", |
| 24 | + "Intended Audience :: Science/Research", |
| 25 | + "Operating System :: MacOS :: MacOS X", |
| 26 | + "Operating System :: Microsoft :: Windows", |
| 27 | + "Operating System :: POSIX :: Linux", |
| 28 | + "Programming Language :: C++", |
| 29 | + "Programming Language :: Python :: 3", |
| 30 | + "Programming Language :: Python :: 3.10", |
| 31 | + "Programming Language :: Python :: 3.11", |
| 32 | + "Programming Language :: Python :: 3.12", |
| 33 | + "Programming Language :: Python :: 3.13", |
| 34 | + "Topic :: Scientific/Engineering :: Artificial Intelligence", |
| 35 | +] |
| 36 | +dependencies = ["numpy>=1.25", "packaging", "mkl>=2024.2; platform_system=='Windows'"] |
| 37 | + |
| 38 | +[project.urls] |
| 39 | +Homepage = "https://github.com/facebookresearch/faiss" |
| 40 | +Documentation = "https://github.com/facebookresearch/faiss/wiki" |
| 41 | +Repository = "https://github.com/facebookresearch/faiss" |
| 42 | +Issues = "https://github.com/facebookresearch/faiss/issues" |
| 43 | + |
| 44 | +[tool.scikit-build] |
| 45 | +cmake.build-type = "Release" |
| 46 | + |
| 47 | +# Exclude C++ headers, cmake configs, and pkgconfig from the wheel. |
| 48 | +# Only the Python package (faiss/) and bundled shared libs remain. |
| 49 | +wheel.exclude = ["include/**", "share/**", "lib/cmake/**", "lib/pkgconfig/**"] |
| 50 | + |
| 51 | +[tool.scikit-build.cmake.define] |
| 52 | +FAISS_OPT_LEVEL = "dd" |
| 53 | +FAISS_ENABLE_GPU = "OFF" |
| 54 | +FAISS_ENABLE_PYTHON = "ON" |
| 55 | +FAISS_ENABLE_MKL = "OFF" |
| 56 | +FAISS_ENABLE_C_API = "OFF" |
| 57 | +FAISS_ENABLE_EXTRAS = "OFF" |
| 58 | +FAISS_ENABLE_SVS = "OFF" |
| 59 | +BUILD_TESTING = "OFF" |
| 60 | +BUILD_SHARED_LIBS = "ON" |
| 61 | + |
| 62 | +[tool.cibuildwheel] |
| 63 | +build = "cp310-* cp311-* cp312-* cp313-*" |
| 64 | +skip = "*-win32 *-manylinux_i686 *-musllinux_*" |
| 65 | +test-requires = ["numpy>=2.0,<3.0", "pytest"] |
| 66 | +test-command = "python -m pytest {project}/tests/test_wheel_smoke.py -v" |
| 67 | + |
| 68 | +[tool.cibuildwheel.linux] |
| 69 | +# EPEL needed for openblas-devel on aarch64 (not in CentOS 7 base repos) |
| 70 | +before-all = "yum install -y epel-release && yum install -y openblas-devel swig" |
| 71 | + |
| 72 | +[tool.cibuildwheel.macos] |
| 73 | +before-all = "brew install libomp openblas swig" |
| 74 | + |
| 75 | +[tool.cibuildwheel.macos.environment] |
| 76 | +# Help CMake find brew-installed OpenBLAS and libomp on macOS. |
| 77 | +# FindOpenMP cannot auto-detect AppleClang + brew libomp, so we pass |
| 78 | +# the flags and library path explicitly. |
| 79 | +CMAKE_PREFIX_PATH = "$(brew --prefix openblas);$(brew --prefix libomp)" |
| 80 | +CMAKE_ARGS = "-DOpenMP_CXX_FLAGS=-Xpreprocessor;-fopenmp;-I$(brew --prefix libomp)/include -DOpenMP_CXX_LIB_NAMES=omp -DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib" |
| 81 | +# Brew libomp targets macOS 14.0+; the wheel must declare the same floor |
| 82 | +# so that delocate does not reject the library. |
| 83 | +MACOSX_DEPLOYMENT_TARGET = "14.0" |
| 84 | + |
| 85 | +[tool.cibuildwheel.windows] |
| 86 | +# Install SWIG and MKL (consistent with conda recipe). |
| 87 | +# MKL is installed via pip into the system Python, then copied to a fixed |
| 88 | +# location (C:\mkl) so FindMKL.cmake can discover it regardless of |
| 89 | +# PEP 517 build isolation. |
| 90 | +before-all = "choco install -y swig && pip install mkl==2024.2.2 mkl-devel==2024.2.2 && python -c \"import os,sys,shutil; os.makedirs('C:/mkl/lib',exist_ok=True); os.makedirs('C:/mkl/bin',exist_ok=True); os.makedirs('C:/mkl/include',exist_ok=True); [shutil.copy2(os.path.join(r,f),'C:/mkl/lib/') for r,_,fs in os.walk(sys.prefix) for f in fs if f.endswith('.lib') and 'mkl' in f]; [shutil.copy2(os.path.join(r,f),'C:/mkl/bin/') for r,_,fs in os.walk(sys.prefix) for f in fs if f.endswith('.dll') and 'mkl' in f]; [shutil.copy2(os.path.join(r,f),'C:/mkl/include/') for r,_,fs in os.walk(sys.prefix) for f in fs if f=='mkl.h']; print('MKL lib:',os.listdir('C:/mkl/lib')); print('MKL bin:',os.listdir('C:/mkl/bin'))\"" |
| 91 | +# Skip delvewheel repair — faiss.dll is co-located with _swigfaiss.pyd in |
| 92 | +# the faiss/ package dir (installed by python/CMakeLists.txt), so Python's |
| 93 | +# DLL loader finds it automatically. MKL runtime DLLs come from the mkl |
| 94 | +# pip package declared in [project] dependencies. |
| 95 | +repair-wheel-command = "" |
| 96 | + |
| 97 | +[tool.cibuildwheel.windows.environment] |
| 98 | +# Dynamic Dispatch is not yet supported on Windows (the DD cmake block is |
| 99 | +# gated behind if(NOT WIN32)). Fall back to generic baseline, matching the |
| 100 | +# conda recipe which also builds "vanilla (no avx)" on Windows. |
| 101 | +# Use MKL for BLAS (consistent with conda). MKLROOT points at the fixed |
| 102 | +# copy created in before-all. We intentionally do NOT override LIB or PATH |
| 103 | +# here — $VAR expansion can fail in cibuildwheel on Windows, clobbering |
| 104 | +# MSVC toolchain paths and breaking pip in the test virtualenv. |
| 105 | +# FindMKL.cmake discovers libraries via MKLROOT alone; MKL runtime DLLs |
| 106 | +# are provided by the mkl pip dependency declared in [project]. |
| 107 | +MKLROOT = "C:/mkl" |
| 108 | +CMAKE_ARGS = "-DFAISS_OPT_LEVEL=generic -DFAISS_ENABLE_MKL=ON -DBLA_VENDOR=Intel10_64_dyn" |
0 commit comments