Skip to content

Commit

Permalink
Revert "embed.h Python 3.11 config.use_environment=1 + PYTHONPATH
Browse files Browse the repository at this point in the history
… test (pybind#4119)"

This reverts commit 2488530.
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Oct 21, 2022
1 parent 2488530 commit 549223a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 27 deletions.
2 changes: 0 additions & 2 deletions include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
#else
PyConfig config;
PyConfig_InitIsolatedConfig(&config);
config.isolated = 0;
config.use_environment = 1;
config.install_signal_handlers = init_signal_handlers ? 1 : 0;

PyStatus status = PyConfig_SetBytesArgv(&config, argc, const_cast<char *const *>(argv));
Expand Down
18 changes: 0 additions & 18 deletions tests/test_embed/catch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@
namespace py = pybind11;

int main(int argc, char *argv[]) {
// Setup for TEST_CASE in test_interpreter.cpp, tagging on a large random number:
std::string updated_pythonpath("pybind11_test_embed_PYTHONPATH_2099743835476552");
const char *preexisting_pythonpath = getenv("PYTHONPATH");
if (preexisting_pythonpath != nullptr) {
#if defined(_WIN32)
updated_pythonpath += ';';
#else
updated_pythonpath += ':';
#endif
updated_pythonpath += preexisting_pythonpath;
}
#if defined(_WIN32)
_putenv_s("PYTHONPATH", updated_pythonpath.c_str());
#else
setenv("PYTHONPATH", updated_pythonpath.c_str(), /*replace=*/1);
#endif

py::scoped_interpreter guard{};

auto result = Catch::Session().run(argc, argv);

return result < 0xff ? result : 0xff;
Expand Down
7 changes: 0 additions & 7 deletions tests/test_embed/test_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ PYBIND11_EMBEDDED_MODULE(throw_error_already_set, ) {
d["missing"].cast<py::object>();
}

TEST_CASE("PYTHONPATH is used to update sys.path") {
// The setup for this TEST_CASE is in catch.cpp!
auto sys_path = py::str(py::module_::import("sys").attr("path")).cast<std::string>();
REQUIRE_THAT(sys_path,
Catch::Matchers::Contains("pybind11_test_embed_PYTHONPATH_2099743835476552"));
}

TEST_CASE("Pass classes and data between modules defined in C++ and Python") {
auto module_ = py::module_::import("test_interpreter");
REQUIRE(py::hasattr(module_, "DerivedWidget"));
Expand Down

0 comments on commit 549223a

Please sign in to comment.