This guide provides instructions for installing Jecq on Linux and Windows. You can either install a pre-built package for Python or build the entire C++ library from its source code.
This is the easiest way to install the Jecq Python package. Pre-built wheels are included with each release.
- Ensure a Python 3.12 environment is activated, for example via miniconda:
conda create -n jecq_test python=3.12 -c conda-forge
conda activate jecq_test-
Download the
.whlwheel file for your platform from the latest release. -
Install the wheel via
pip:
pip install <path_to_downloaded_wheel>Building from source is recommended for developers who need to modify the C++ core or link against it in their own applications. It is also necessary if no wheel file is available for your platform or Python version.
For Faiss Developers: If you are already building Faiss, the process for Jecq is nearly identical and supports the same CMake flags.
The basic requirements are a C++ 17 compiler and a BLAS implementation.
# This script installs required build dependencies using the 'apt' package manager.
./install_requirements.shFor best performance on Intel CPUs, we also recommend installing the Intel MKL library:
# This script downloads and installs the Intel MKL library.
./install_mkl.shYou will need to install several tools to create a build environment. We recommend using a Developer PowerShell for Visual Studio terminal run as Administrator for these steps.
-
Visual Studio Build Tools: Download and run the Visual Studio Installer. During installation, select the "Desktop Development with C++" workload. This includes the C++ compiler and MSBuild.
-
Intel® oneAPI Math Kernel Library (MKL): Jecq uses MKL for high-performance computations. Install it from the Intel oneMKL page or use winget.
winget install --id=Intel.oneMKL -e --accept-package-agreements --accept-source-agreements- CMake: This tool generates the build files for Visual Studio. Install it from the CMake download page or use winget.
winget install -e --id Kitware.CMake-
Python: Install a recent version of Python from the official Python website or the Microsoft Store.
-
vcpkg (C++ Package Manager): We use vcpkg to manage C++ dependencies.
# Clone vcpkg to a permanent location, for example C:\vcpkg
git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
# Run the bootstrap script to build vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
# Integrate vcpkg with MSBuild for all users
vcpkg integrate install- Set up vcpkg Environment Variable:
Important: The build system finds vcpkg through an environment variable. Setting it in PowerShell with $env:VCPKG_ROOT is temporary and only lasts for the current session. For a permanent, more reliable setup, follow these steps:
- In the Windows Start Menu, type env and select "Edit the system environment variables".
- In the System Properties window, click the "Environment Variables..." button.
- In the "System variables" section, click "New...".
- For "Variable name", enter VCPKG_ROOT.
- For "Variable value", enter the path to your vcpkg installation (e.g., C:\vcpkg).
- Click OK on all windows. You will need to restart your PowerShell terminal for this change to take effect.
- gflags (Dependency): Install the gflags library using vcpkg.
vcpkg install gflags:x64-windowsAfter installing all prerequisites, you can build the project.
This is the fastest way to compile the library and its Python bindings.
# This script runs cmake to configure and make to compile the project.
./build.shNote: Ensure you are in a Developer PowerShell for Visual Studio where the prerequisites are available.
# This script runs cmake to configure and msbuild to compile the project.
./build.ps1This gives you more control over the build process.
- Configure with CMake This step generates the project files for your native build system.
cmake -B build_linux .# This command assumes Visual Studio 2022.
cmake -B build . -G "Visual Studio 17 2022"You can pass Jecq- and Faiss-specific flags here. For example, use -DJECQ_ENABLE_PYTHON=OFF to disable the Python bindings and -DBUILD_TESTING=ON to enable C++ tests.
- Compile with Make / MSBuild This step uses the generated files to compile the C++ code.
# The -j flag enables parallel compilation; adjust the number for your CPU cores.
make -C build_linux -j8# This command builds the entire solution in RelWithDebInfo configuration.
msbuild build/jecq.sln /p:Configuration=RelWithDebInfo- Build Python Bindings (Optional) If you enabled Python bindings, this step builds and installs the Python package.
pushd ./build_linux/jecq/python
python3 setup.py install
popdPush-Location ./build/jecq/python
python setup.py install
Pop-LocationIf you configured CMake with -DBUILD_TESTING=ON, you can run the C++ test suite to verify the build.
./build_linux/tests/jecq_test# The .exe is located in the RelWithDebInfo folder for a RelWithDebInfo build.
./build/tests/RelWithDebInfo/jecq_test.exeThe demos folder contains sample scripts that compare Jecq and Faiss, allow for hyper-parameterization and more.
# This script prepares the Python environment for the demos.
./build_demo.sh
source ./build_linux/.venv/bin/activate
python3 ./demos/demo_sample_search.py# This script prepares the Python environment for the demos.
./build_demo.ps1
python ./demos/demo_sample_search.py