Skip to content

Commit

Permalink
⏪ add MQT::CorePython target back (#541)
Browse files Browse the repository at this point in the history
## Description

As the integration of the mqt-core Python package into the top-level
tools turned out to be a much lengthier process than imagined, this PR
adds back the `MQT::CorePython` target that was previously used to read
in Qiskit objects.
This should allow development in the top-level libraries to continue
without waiting for the remaining issues with the Python package being
resolved.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.

---------

Signed-off-by: burgholzer <[email protected]>
  • Loading branch information
burgholzer authored Jan 29, 2024
1 parent bd2fd7b commit 3d5e14b
Show file tree
Hide file tree
Showing 3 changed files with 552 additions and 0 deletions.
49 changes: 49 additions & 0 deletions include/mqt-core/python/qiskit/QuantumCircuit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

#include "pybind11/pybind11.h"

Check failure on line 3 in include/mqt-core/python/qiskit/QuantumCircuit.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/mqt-core/python/qiskit/QuantumCircuit.hpp:3:10 [clang-diagnostic-error]

'pybind11/pybind11.h' file not found
#include "pybind11/pytypes.h"

#include <regex>
#include <type_traits>
#include <variant>

namespace py = pybind11;

#include "QuantumComputation.hpp"

namespace qc::qiskit {
using namespace pybind11::literals;

class QuantumCircuit {
public:
static void import(QuantumComputation& qc, const py::object& circ);

protected:
static void emplaceOperation(QuantumComputation& qc,
const py::object& instruction,
const py::list& qargs, const py::list& cargs,
const py::list& params, const py::dict& qubitMap,
const py::dict& clbitMap);

static SymbolOrNumber parseSymbolicExpr(const py::object& pyExpr);

static SymbolOrNumber parseParam(const py::object& param);

static void addOperation(QuantumComputation& qc, OpType type,
const py::list& qargs, const py::list& params,
const py::dict& qubitMap);

static void addTwoTargetOperation(QuantumComputation& qc, OpType type,
const py::list& qargs,
const py::list& params,
const py::dict& qubitMap);

static void importDefinition(QuantumComputation& qc, const py::object& circ,
const py::list& qargs, const py::list& cargs,
const py::dict& qubitMap,
const py::dict& clbitMap);

static void importInitialLayout(QuantumComputation& qc,
const py::object& circ);
};
} // namespace qc::qiskit
23 changes: 23 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ add_subdirectory(zx)
# add ECC library
add_subdirectory(ecc)

# ** Note ** The following target will soon be removed from the project. All top-level projects
# should switch to using the mqt-core Python package.
if(BINDINGS AND NOT TARGET mqt-core-python)
# add Python interface library
add_library(
${MQT_CORE_TARGET_NAME}-python ${MQT_CORE_INCLUDE_BUILD_DIR}/python/qiskit/QuantumCircuit.hpp
python/qiskit/QuantumCircuit.cpp)

# link with main project library and pybind11 libraries
target_link_libraries(${MQT_CORE_TARGET_NAME}-python PUBLIC MQT::Core pybind11::pybind11)
target_link_libraries(${MQT_CORE_TARGET_NAME}-python PRIVATE MQT::ProjectOptions
MQT::ProjectWarnings)

# add MQT alias
add_library(MQT::CorePython ALIAS ${MQT_CORE_TARGET_NAME}-python)
set_target_properties(
${MQT_CORE_TARGET_NAME}-python
PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
EXPORT_NAME CorePython)
list(APPEND MQT_CORE_TARGETS ${MQT_CORE_TARGET_NAME}-python)
endif()

if(BUILD_MQT_CORE_BINDINGS)
add_subdirectory(python)
endif()
Expand Down
Loading

0 comments on commit 3d5e14b

Please sign in to comment.