|
27 | 27 | - A C++ compiler that supports C++11
|
28 | 28 | - CMake >= 3.18
|
29 | 29 | - [Pulsar C++ client library](https://github.com/apache/pulsar-client-cpp)
|
30 |
| -- [Boost.Python](https://github.com/boostorg/python) |
| 30 | +- [PyBind11](https://github.com/pybind/pybind11) |
31 | 31 |
|
32 |
| -## Install the Python wheel |
33 |
| - |
34 |
| -### Windows (with Vcpkg) |
| 32 | +PyBind11 is a header-only library and a submodule, so you can simply download the submodule so that CMake can find this dependency. |
35 | 33 |
|
36 |
| -First, install the dependencies via [Vcpkg](https://github.com/microsoft/vcpkg). |
37 |
| - |
38 |
| -```PowerShell |
39 |
| -vcpkg install --feature-flags=manifests --triplet x64-windows |
| 34 | +```bash |
| 35 | +git submodule update --init |
40 | 36 | ```
|
41 | 37 |
|
42 |
| -> NOTE: For Windows 32-bit library, change `x64-windows` to `x86-windows`, see [here](https://github.com/microsoft/vcpkg/tree/master/triplets) for all available triplets. |
| 38 | +You can also download the pybind11 directly like: |
43 | 39 |
|
44 |
| -Then, build and install the Python wheel. |
45 |
| - |
46 |
| -```PowerShell |
47 |
| -# Assuming the Pulsar C++ client has been installed under the `PULSAR_CPP` directory. |
48 |
| -cmake -B build -DUSE_VCPKG=ON -DCMAKE_PREFIX_PATH="$env:PULSAR_CPP" -DLINK_STATIC=ON |
49 |
| -cmake --build build --config Release |
50 |
| -cmake --install build |
51 |
| -py setup.py bdist_wheel |
52 |
| -py -m pip install ./dist/pulsar_client-*.whl |
| 40 | +```bash |
| 41 | +pip3 install pyyaml |
| 42 | +export PYBIND11_VERSION=$(./build-support/dep-version.py pybind11) |
| 43 | +curl -L -O https://github.com/pybind/pybind11/archive/refs/tags/v${PYBIND11_VERSION}.tar.gz |
| 44 | +tar zxf v${PYBIND11_VERSION}.tar.gz |
| 45 | +mv pybind11-${PYBIND11_VERSION} pybind11 |
53 | 46 | ```
|
54 | 47 |
|
55 |
| -Since the Python client links to Boost.Python dynamically, you have to copy the dll (e.g. `boost_python310-vc142-mt-x64-1_80.dll`) into the system path (the `PATH` environment variable). If the `-DLINK_STATIC=ON` option is not specified, you have to copy the `pulsar.dll` into the system path as well. |
| 48 | +After that, you only need to install the Pulsar C++ client dependency into the system path. You can [install the pre-built binaries](https://pulsar.apache.org/docs/next/client-libraries-cpp/#installation) or [build from source](https://github.com/apache/pulsar-client-cpp#compilation). |
56 | 49 |
|
57 |
| -### Linux or macOS |
| 50 | +## Install the Python wheel |
58 | 51 |
|
59 |
| -Assuming the Pulsar C++ client and Boost.Python have been installed under the system path. |
| 52 | +Make sure the PyBind11 submodule has been downloaded and the Pulsar C++ client has been installed. Then run the following commands: |
60 | 53 |
|
61 | 54 | ```bash
|
62 | 55 | cmake -B build
|
63 |
| -cmake --build build -j8 |
| 56 | +cmake --build build |
64 | 57 | cmake --install build
|
65 |
| -./setup.py bdist_wheel |
66 |
| -pip3 install dist/pulsar_client-*.whl --force-reinstall |
| 58 | +python3 ./setup.py bdist_wheel |
| 59 | +python3 -m pip install dist/pulsar_client-*.whl --force-reinstall |
67 | 60 | ```
|
68 | 61 |
|
69 | 62 | > **NOTE**
|
70 | 63 | >
|
71 | 64 | > 1. Here a separate `build` directory is created to store all CMake temporary files. However, the `setup.py` requires the `_pulsar.so` is under the project directory.
|
72 | 65 | > 2. Add the `--force-reinstall` option to overwrite the existing Python wheel in case your system has already installed a wheel before.
|
| 66 | +> 3. On Windows, the Python command is `py` instead of `python3`. |
73 | 67 |
|
74 | 68 | ## Running examples
|
75 | 69 |
|
|
0 commit comments