How would I go about incorporating C++ tests into this?
Closed this issue · 1 comments
sodiumnitrate commented
I'm working on a few python packages using this setup, and there is extra code/functionality on the C++ side that I don't expose to python. I'd like to be able to write unit tests, perhaps using GTEST, that I can integrate into this setup. I attempted incorporating the setup in this tutorial, but I'm unclear about a few things. The way that I understand it, a possible solution could be:
- Have a github action run tests separately, following an explicit build, not with
pip
, and then manually run the tests. Perhaps something like this. - This seems to require fetching
pybind11
explicitly withinCMakeLists.txt
. I'm not sure if this is fine. - This also probably requires
CMakeLists.txt
files that would work both withpip
andcmake
. (I'm a beginner incmake
, so I'm assuming there's a way to do this.)
Can someone chime in? Am I overcomplicating things?
sodiumnitrate commented
Okay, I found this example by the same author, and modified it to use scikit-build
only, and not setuptools
.
Essentially:
- delete
setup.py
- change the content of
pyproject.toml
to something like:
[build-system]
requires = [
"scikit-build-core>=0.3.3",
"cmake>=3.14",
"ninja",
"pybind11>=2.6"
]
build-backend = "scikit_build_core.build"
[project]
name = "hello-cmake-scikit"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.10"
[project.optional-dependencies]
test = ["pytest"]
and follow the instructions in the example, basically. Closing this, but feel free to reopen if I'm doing something egregiously wrong.