Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
wrap
pybind11
tests
test_cmake_build
embed.cpp
Go to the documentation of this file.
1
#include <
pybind11/embed.h
>
2
namespace
py
=
pybind11
;
3
4
PYBIND11_EMBEDDED_MODULE
(test_cmake_build,
m
) {
5
m
.def(
"add"
, [](
int
i
,
int
j
) {
return
i
+
j
; });
6
}
7
8
int
main
(
int
argc,
char
*argv[]) {
9
if
(argc != 2) {
10
throw
std::runtime_error(
"Expected test.py file as the first argument"
);
11
}
12
auto
*test_py_file = argv[1];
13
14
py::scoped_interpreter guard{};
15
16
auto
m
= py::module_::import(
"test_cmake_build"
);
17
if
(
m
.attr(
"add"
)(1, 2).cast<
int
>() != 3) {
18
throw
std::runtime_error(
"embed.cpp failed"
);
19
}
20
21
py::module_::import(
"sys"
).attr(
"argv"
) =
py::make_tuple
(
"test.py"
,
"embed.cpp"
);
22
py::eval_file
(test_py_file,
py::globals
());
23
}
main
int main(int argc, char *argv[])
Definition:
embed.cpp:8
j
std::ptrdiff_t j
Definition:
tut_arithmetic_redux_minmax.cpp:2
make_tuple
tuple make_tuple()
Definition:
cast.h:1390
embed.h
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
PYBIND11_EMBEDDED_MODULE
PYBIND11_EMBEDDED_MODULE(test_cmake_build, m)
Definition:
embed.cpp:4
eval_file
object eval_file(str fname, object global=globals(), object local=object())
Definition:
eval.h:112
pybind11
Definition:
wrap/pybind11/pybind11/__init__.py:1
globals
dict globals()
Definition:
pybind11.h:1323
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:01:38