PureCPP is a powerful C++ backend architecture for RAG systems.
Designed for maximum performance and scalability, it integrates vector search, ONNX models, and CPU/CUDA acceleration into a seamless, Python-integrated framework.
This repository provides detailed guidance on how to set up the environment, configure dependencies, and build the project.
├── scripts/ # Shell utilities and setup scripts
├── package/ # Python package
│ └── purecpp/ # Contains the compiled .so
├── libs/ # Dependencies
├── src/ # source files and CMake entry
│ ├── build/ # Generated build files
│ ├── Conanfile.py # Package manager for C and C++
│ └── CMakeLists.txt # Main build config
├── models/
│ ├── hf_extract_model.py
│ ├── hf_model_to_onnx.py
│ └── <Model>/
├── Dockerfile # Build environment
└── README.mdgit clone --recursive https://github.com/pureai-ecosystem/purecpp
cd purecppWarning
If you forgot to use --recursive when cloning the repository,
make sure to run:
git submodule update --init --recursive-
1. Build a Docker image from the current directory and tag it as 'purecpp_env'
docker build -t purecpp_env . -
2. Start a Docker container named 'env' from the 'purecpp_env' image, mounting current dir to /home
docker run -it --name env -v "$PWD":/home purecpp_env -
3. Execute the
env_config.shchmod +x scripts/*.sh ./scripts/env_config.shThis script automates the setup. Installing Python essentials, LibTorch, FAISS, and configuring Conan profile
Caution
Once you've created the container using docker run, you don't need to recreate it again.
Instead, follow these two simple commands to reuse the container:
docker start envThis command starts an existing container that has already been created earlier using docker run.
docker exec -it env bashThis command attaches a terminal to the running container, allowing you to interact with it just like you would with a regular Linux shell.
Requirements
- Python ≥ 3.8
- CMake ≥ 3.22
- GCC/G++ ≥ 13
-
Ubuntu/Debian
sudo apt update && \ sudo apt upgrade -y && \ sudo apt install -y \ build-essential wget curl \ ninja-build cmake libopenblas-dev \ libgflags-dev python3-dev libprotobuf-dev \ protobuf-compiler unzip libssl-dev zlib1g-dev
-
Red Hat
yum update && yum install -y \ gcc gcc-c++ make git curl wget \ ninja-build libffi-devel openssl-devel \ protobuf-devel gflags-devel zlib-devel \ openblas-devel unzip \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -yRun rustup installer non-interactively (-y).
source ~/.cargo/envThis places cargo and rustc in /root/.cargo & activate Rust Environment
In case you do not have a Docker environment available, we strongly recommend that you use a Python venv (virtual environment) to ensure proper isolation of dependencies and reproducibility of results.
-
Create the virtual environment (replace 'venv' with your preferred name)
python3 -m venv venv
-
Activate the virtual environment on Linux or macOS
source venv/bin/activate
This practice minimizes conflicts between global packages and project-specific requirements.
Then run env_config.sh script
chmod +x scripts/*.sh
./scripts/env_config.shThis script automates the setup. Installing Python essentials, LibTorch, FAISS, and configuring Conan profile
The build.sh is a development pipeline, that makes easier to compile and test
chmod +x build.sh
./build.sh- Cleans the
build/folder - Installs Conan dependencies if missing
- Compiles the code
- Sends the
RagPUREAI.*.sooutput toSandbox/
The build.sh script will place the resulting libraries inside Sandbox/
Sandbox/
├── Resources/
├── RagPUREAI.cpython-312-x86_64-linux-gnu.so
└── YOUR-TEST.pyTo test the Python bindings:
from RagPUREAI import SomeExposedFunction To build and upload the Python package to PyPI:
./scripts/create_pip_package PYPI-API-KEYThis script will:
- Copy the
.sofile to the appropriate location. - Package the Python module using
setuptools. - Upload to PyPI using
twine.
Stay tuned for updates and new model integrations! 🚀
