-
Notifications
You must be signed in to change notification settings - Fork 63
Request for Example: Linking Python Module with Shared Library using scikit-build-core and pybind11/nanobind #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Disclaimer: not a scikit-build-core developer, just a happy user Honestly, the documentation on CMake, scikit-build-core and pybind11/nanobind makes this procedure seem more "magical" than it actually is. Once you actually try it, it's pretty straightforward to apply it everywhere. I'm assuming you are aiming for making your Python wheels redistributable, so in the below I will assume you are using Apple Clang on MacOS, and GCC on GNU/Linux (I don't have too much experience on Windows so I'll only provide limited remarks). It should apply to both C and C++ extensions. I will not cover how to write your Python bindings since that's explained in great detail in both nanobind and pybind11 docs. Instead, I will mainly focus on gluing all of this together with CMake and scikit-build-core. Building Python extensions with CMakeThe CMake part is relatively straightforward, and is composed of the following procedure:
scikit-build-core and CMake/pyproject.tomlMost of the config I've used on the Python side is via
|
Oh, many appologise that we didn't catch this issue. Great writeup on this @JCGoran Minor notes:
Can you open an issue to investigate this? Afaiu |
I think you misunderstood my question. My issue isn't about connecting Let’s say I’ve downloaded the There are many non-trivial linking challenges when writing the A complete and solid example of this workflow is badly needed in this area. |
Hi scikit-build-core team! I'm working on a project where I need to connect my Python code with a shared library (like
my_shared.so
), and I'd love to use scikit-build-core for this, along with eitherpybind11
ornanobind
(I prefer nanobind) for the bindings.I've been looking through the documentation, but a clear example showing this specific workflow would be really helpful. It would be great to see how to set up a project with scikit-build-core, build a simple shared library with C/C++ functions, generate Python bindings, configure the linking process, and finally, use those functions in a Python script.
My goal is to bring a custom C/C++ library into my Python project, and I think scikit-build-core with pybind11 or nanobind is the perfect tool for the job. An example would make it much easier to understand and use this approach.
Having this example would be a huge help to the scikit-build-core community, especially for those who are new to linking with shared libraries. It would simplify things and enable developers to use their existing C/C++ code in Python projects more effectively.
Thank you for considering this! A practical example would be a valuable addition to the documentation, showing the real-world power of scikit-build-core.
The text was updated successfully, but these errors were encountered: