-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pydrake: Add
UpdateGlobalsFromModule
test utility
- Loading branch information
1 parent
a2fc39e
commit d774035
Showing
7 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "pybind11/pybind11.h" | ||
|
||
#include "drake/bindings/pydrake/pydrake_pybind.h" | ||
|
||
namespace drake { | ||
namespace pydrake { | ||
namespace test { | ||
|
||
// TODO(eric.cousineau): Figure out if there is a better solution than this | ||
// hack. | ||
/// pybind11's Python3 implementation seems to disconnect the `globals()` from | ||
/// a embedded interpreter's `__main__` module. To remedy this, we must | ||
/// manually synchronize these variables. | ||
inline void UpdateGlobalsFromModule(py::module m) { | ||
py::globals().attr("update")(m.attr("__dict__")); | ||
} | ||
|
||
} // namespace test | ||
} // namespace pydrake | ||
} // namespace drake |