diff --git a/pyproject.toml b/pyproject.toml index 86458d238..66a1de8c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,7 @@ ninja.version = ">=1.10" build-dir = "build/{wheel_tag}/{build_type}" # Only build the Python bindings target -build.targets = ["ir"] +build.targets = ["ir", "na"] # Only install the Python package component install.components = ["mqt-core_Python"] diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 07d753def..cfd17992d 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -1,2 +1,4 @@ # add the IR bindings package add_subdirectory(ir) +# add the NA bindings package +add_subdirectory(na) diff --git a/src/python/na/CMakeLists.txt b/src/python/na/CMakeLists.txt new file mode 100644 index 000000000..62903dab4 --- /dev/null +++ b/src/python/na/CMakeLists.txt @@ -0,0 +1,23 @@ +if(NOT TARGET na) + # collect source files + file(GLOB_RECURSE NA_SOURCES **.cpp) + + # declare the Python module + pybind11_add_module( + # Name of the extension + na + # Prefer thin LTO if available + THIN_LTO + # Optimize the bindings for size + OPT_SIZE + # Source code goes here + ${MQT_CORE_INCLUDE_BUILD_DIR}/python/pybind11.hpp + ${NA_SOURCES}) + target_link_libraries(na PRIVATE MQT::CoreNA MQT::ProjectOptions MQT::ProjectWarnings) + + # Install directive for scikit-build-core + install( + TARGETS na + DESTINATION . + COMPONENT ${MQT_CORE_TARGET_NAME}_Python) +endif() diff --git a/src/python/na/register_na_computation.cpp b/src/python/na/register_na_computation.cpp new file mode 100644 index 000000000..4a74a651c --- /dev/null +++ b/src/python/na/register_na_computation.cpp @@ -0,0 +1,26 @@ +#include "na/NAComputation.hpp" +#include "python/pybind11.hpp" + +namespace mqt { + +void registerNAComputation(py::module& m) { + + auto qc = py::class_(m, "NAComputation"); + + ///--------------------------------------------------------------------------- + /// \n Constructors \n + ///--------------------------------------------------------------------------- + + qc.def(py::init<>(), "Constructs an empty NAComputation."); + + ///--------------------------------------------------------------------------- + /// \n String Serialization \n + ///--------------------------------------------------------------------------- + /// + qc.def("__str__", + [](const na::NAComputation& circ) { return circ.toString(); }); +} + +PYBIND11_MODULE(na, m, py::mod_gil_not_used()) { registerNAComputation(m); } + +} // namespace mqt