Skip to content

obatistaSungrow/sortcpp

 
 

Repository files navigation

sortcpp

Bazel, C++ and pybind11 sample with c++ tests, python tests and python wheel packaging.

Inspired by Mizux/bazel-pybind11

Features

  • bazel modules
  • bazelisk
  • gazelle with python plugin
  • buildifier
  • usage of numpy dependancy

IDE

VS Code

  • starlark autocompletion link
  • c++ autocompletion link
  • python autocompletion link

Prerequisites

How to use:

Test

Test all targets

bazel test //...

Test individual targets

bazel test //sortcpp/src:sortcpp_test
bazel test //sortcpp:sortcpp_test

To see stdout check the log files or use bazel run

bazel run //sortcpp/src:sortcpp_test
bazel run //sortcpp:sortcpp_test

Build

To build all targets in the workspace

bazel build //...

Build python wheel

bazel build //sortcpp:wheel
tar tvf $(bazel cquery //sortcpp:wheel --output files 2>/dev/null)

Install python wheel

bazel build //sortcpp:wheel
tar tvf $(bazel cquery //sortcpp:wheel --output files 2>/dev/null)
pip install $(bazel cquery //src/python:wheel --output files 2>/dev/null) --force-reinstall

How to use the installed python package

from sortcpp import sort_array
sort_array([9, 5, 3])
sort_array([9, -1, 10, 0, 3])

Build in docker

docker run \
  --platform linux/amd64 \
  --entrypoint /bin/bash \
  -v "$(pwd)":/src/workspace \
  -v /tmp/build_output:/tmp/build_output \
  -w /src/workspace \
  gcr.io/bazel-public/bazel:8.0.1 \
  -c "bazel build //... && bazel test //... && bazel build //sortcpp:wheel"

Other examples on how to build python wheels

TODO

  • Configure Renovate to keep the dependencies up-to-date

About

Bazel C++ Pybind11 VSCode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Starlark 69.6%
  • C++ 17.2%
  • Python 13.2%