aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/docs/advanced/embedding.rst
diff options
context:
space:
mode:
authorMiodrag Milanović <mmicko@gmail.com>2021-01-02 11:16:49 +0100
committerGitHub <noreply@github.com>2021-01-02 11:16:49 +0100
commit9b9628047c01a970cfe20f83f2b7129ed109440d (patch)
tree1db418e9a889dc6fbe6199c5259aac9bd8cbb32f /3rdparty/pybind11/docs/advanced/embedding.rst
parentc6cdf30501dcb2da01361229dd66a05dad73a132 (diff)
parent61b07bc9a664d6a88b85aae99f9756d7569688a9 (diff)
downloadnextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.gz
nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.bz2
nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.zip
Merge pull request #549 from YosysHQ/update
Update pybind11 version and fix for future python versions
Diffstat (limited to '3rdparty/pybind11/docs/advanced/embedding.rst')
-rw-r--r--3rdparty/pybind11/docs/advanced/embedding.rst16
1 files changed, 8 insertions, 8 deletions
diff --git a/3rdparty/pybind11/docs/advanced/embedding.rst b/3rdparty/pybind11/docs/advanced/embedding.rst
index 39303160..dfdaad2d 100644
--- a/3rdparty/pybind11/docs/advanced/embedding.rst
+++ b/3rdparty/pybind11/docs/advanced/embedding.rst
@@ -18,7 +18,7 @@ information, see :doc:`/compiling`.
.. code-block:: cmake
- cmake_minimum_required(VERSION 3.0)
+ cmake_minimum_required(VERSION 3.4)
project(example)
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`
@@ -108,11 +108,11 @@ The two approaches can also be combined:
Importing modules
=================
-Python modules can be imported using `module::import()`:
+Python modules can be imported using `module_::import()`:
.. code-block:: cpp
- py::module sys = py::module::import("sys");
+ py::module_ sys = py::module_::import("sys");
py::print(sys.attr("path"));
For convenience, the current working directory is included in ``sys.path`` when
@@ -128,12 +128,12 @@ embedding the interpreter. This makes it easy to import local Python files:
.. code-block:: cpp
- py::module calc = py::module::import("calc");
+ py::module_ calc = py::module_::import("calc");
py::object result = calc.attr("add")(1, 2);
int n = result.cast<int>();
assert(n == 3);
-Modules can be reloaded using `module::reload()` if the source is modified e.g.
+Modules can be reloaded using `module_::reload()` if the source is modified e.g.
by an external process. This can be useful in scenarios where the application
imports a user defined data processing script which needs to be updated after
changes by the user. Note that this function does not reload modules recursively.
@@ -153,7 +153,7 @@ like any other module.
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(fast_calc, m) {
- // `m` is a `py::module` which is used to bind functions and classes
+ // `m` is a `py::module_` which is used to bind functions and classes
m.def("add", [](int i, int j) {
return i + j;
});
@@ -162,7 +162,7 @@ like any other module.
int main() {
py::scoped_interpreter guard{};
- auto fast_calc = py::module::import("fast_calc");
+ auto fast_calc = py::module_::import("fast_calc");
auto result = fast_calc.attr("add")(1, 2).cast<int>();
assert(result == 3);
}
@@ -196,7 +196,7 @@ naturally:
int main() {
py::scoped_interpreter guard{};
- auto py_module = py::module::import("py_module");
+ auto py_module = py::module_::import("py_module");
auto locals = py::dict("fmt"_a="{} + {} = {}", **py_module.attr("__dict__"));
assert(locals["a"].cast<int>() == 1);