diff options
author | David Shah <dave@ds0.me> | 2020-07-27 13:50:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-27 13:50:42 +0100 |
commit | b39a2a502065ec1407417ffacdac2154385bf80f (patch) | |
tree | 3349c93ac87f5758009c53b3e2eb5b9a130cd0d6 /common/pybindings.h | |
parent | e6991ad5dc79f6118838f091cc05f10d3377eb4a (diff) | |
parent | fe398ab983aee9283f61c288dc98d94542c30332 (diff) | |
download | nextpnr-b39a2a502065ec1407417ffacdac2154385bf80f.tar.gz nextpnr-b39a2a502065ec1407417ffacdac2154385bf80f.tar.bz2 nextpnr-b39a2a502065ec1407417ffacdac2154385bf80f.zip |
Merge pull request #477 from YosysHQ/pybind11
Move to pybind11
Diffstat (limited to 'common/pybindings.h')
-rw-r--r-- | common/pybindings.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/common/pybindings.h b/common/pybindings.h index c4d84442..d7429ed0 100644 --- a/common/pybindings.h +++ b/common/pybindings.h @@ -22,9 +22,8 @@ #define COMMON_PYBINDINGS_H #include <Python.h> -#include <boost/python.hpp> -#include <boost/python/suite/indexing/map_indexing_suite.hpp> -#include <boost/python/suite/indexing/vector_indexing_suite.hpp> +#include <iostream> +#include <pybind11/pybind11.h> #include <stdexcept> #include <utility> #include "pycontainers.h" @@ -34,7 +33,7 @@ NEXTPNR_NAMESPACE_BEGIN -using namespace boost::python; +namespace py = pybind11; std::string parse_python_exception(); @@ -46,9 +45,9 @@ template <typename Tn> void python_export_global(const char *name, Tn &x) return; d = PyModule_GetDict(m); try { - PyObject *p = incref(object(boost::ref(x)).ptr()); - PyDict_SetItemString(d, name, p); - } catch (boost::python::error_already_set const &) { + py::object obj = py::cast(x, py::return_value_policy::reference); + PyDict_SetItemString(d, name, obj.ptr()); + } catch (py::error_already_set const &) { // Parse and output the exception std::string perror_str = parse_python_exception(); std::cout << "Error in Python: " << perror_str << std::endl; |