cmeel-boost: Boost C++ Libraries for CMake-based Python Wheels

1.89.0 · active · verified Tue Apr 14

cmeel-boost is a cmeel distribution that packages the widely used Boost C++ source libraries. It enables Python projects that utilize `cmeel` as their build backend to seamlessly incorporate and link against Boost C++ components within their CMake-based build process. The library aims to simplify the distribution of Boost for Python wheels. Version 1.89.0 is the latest stable release, with a release cadence that often aligns with upstream Boost versions.

Warnings

Install

Imports

Quickstart

cmeel-boost is designed to be a build dependency for other Python packages that wrap C++ code requiring Boost. The quickstart illustrates how a `pyproject.toml` declares `cmeel-boost` as a build-system requirement. Subsequently, a `CMakeLists.txt` within the C++ portion of the project can locate and link against Boost components provided by `cmeel-boost` using standard CMake `find_package` commands. The actual C++ code would then include Boost headers and use its functionalities. The `cmeel` backend automatically sets `CMAKE_PREFIX_PATH` to enable CMake to find installed `cmeel` packages like `cmeel-boost`.

# Assume a C++ project 'my_cpp_lib' that uses Boost.
#
# 1. pyproject.toml for a Python package that depends on my_cpp_lib
#    and needs cmeel-boost as a build dependency:
#
# [build-system]
# requires = ["cmeel[build]", "cmeel-boost~=1.89.0"]
# build-backend = "cmeel.build"
#
# [project]
# name = "my-python-package"
# version = "0.1.0"
#
# 2. CMakeLists.txt for my_cpp_lib (e.g., in a 'src' subdirectory):
#
# cmake_minimum_required(VERSION 3.15)
# project(my_cpp_lib LANGUAGES CXX)
#
# # Find Boost components. cmeel-boost will have installed Boost
# # in a location discoverable by CMake through CMAKE_PREFIX_PATH set by cmeel.
# find_package(Boost 1.89.0 REQUIRED COMPONENTS system thread)
#
# add_library(my_cpp_lib SHARED my_cpp_lib.cpp)
# target_include_directories(my_cpp_lib PUBLIC ${Boost_INCLUDE_DIRS})
# target_link_libraries(my_cpp_lib PUBLIC Boost::system Boost::thread)
#
# 3. my_cpp_lib.cpp (example C++ file using Boost):
#
# #include <iostream>
# #include <boost/version.hpp>
# #include <boost/system/error_code.hpp>
#
# extern "C" void say_boost_version() {
#    std::cout << "Boost Version: " << BOOST_VERSION / 100000 << ".";
#    std::cout << (BOOST_VERSION / 100 % 1000) << ".";
#    std::cout << (BOOST_VERSION % 100) << std::endl;
#    boost::system::error_code ec;
#    // Example use, not doing anything meaningful with ec here
#    if (ec) {
#        std::cerr << "Error: " << ec.message() << std::endl;
#    }
# }
#
# 4. To build a wheel for 'my-python-package':
#    (Ensure your environment has a C++ compiler compatible with Boost.)
#    python -m pip wheel .

# Note: This code block demonstrates the C++/CMake usage. The `python -m cmeel cmake` command 
# is typically run internally by `pip` when building a `cmeel`-based package that depends on `cmeel-boost`.
# For debugging or manual usage in a C++ project outside `cmeel`, you might run:
# export CMAKE_PREFIX_PATH=$(python -m cmeel cmake)
# cmake -S . -B build
# cmake --build build

import os

# Placeholder for a Python script that might invoke the C++ library (if bindings existed)
# cmeel-boost itself does not provide Python callable functions.
print("cmeel-boost provides C++ libraries, not direct Python imports for Boost functionality.")
print("To use it, your Python package must be built with cmeel and link against Boost in its CMake project.")

view raw JSON →