Although most of the examples and Boost’s documentation uses bjam, you can also use CMake for your Boost.Python projects. A minimal CMakeLists.txt to compile your Python library is provided below.

cmake_minimum_required(VERSION 3.10)

find_package(Boost COMPONENTS system python3 REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)

add_library(yourlib MODULE your_lib.cpp your_other_files.cpp)

You may want to compile Boost as a static library such that you only have to ship one file. This can be achieved by providing cxxflags="-fPIC" link=static install to b2 when compiling Boost from source. I personally always use Docker containers (one for each Python version with the correct header files) and use the following command to integrate the statically-linked boost library into the container:

RUN curl -LO && tar -xvf boost_1_77_0.tar.gz && \
    cd boost_1_77_0 && ./ && ./b2 cxxflags="-fPIC" link=static install && cd .. && rm -rf boost*