Requirements:
- python (suggest >=3.9)
- C++ compiler (gcc, msvc, clang should work)
If you don't have a useable Python environment available, then:
- Download and install miniforge: https://github.com/conda-forge/miniforge
- Create a new environment
mamba create -n pbdemo "python<3.11" setuptools pip
mamba activate pbdemo
At that point, pip install . should work.
After running pip install ., import Python module and check doc string is available
>>> from pbstring import pbstring
>>> pbstring.__doc__
'Hi!'
If you want to run the build via cmake directly, for more control, then do the following:
- Install pybind11 (this must be done in the active environment for a cmake-driven build)
pip install "pybind11[global]"
- Build the code
git clone <uri>
cd <repo>
mkdir bld
cmake ..
cmake --build .
- Load the module from within the build directory:
cd bld
ls # you should see an extension like `pbstring.cpython-310-darwin.so`
python
>>> import pbstring
>>> pbstring.__doc__
'Hi!'