mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-30 04:11:00 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2896afa014 |
@@ -6,6 +6,7 @@
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
#include <pybind11/embed.h>
|
#include <pybind11/embed.h>
|
||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
|
|
||||||
@@ -25,8 +26,15 @@ void ensure_python_initialized()
|
|||||||
config.parse_argv = 0;
|
config.parse_argv = 0;
|
||||||
|
|
||||||
const auto python_home = boost::dll::program_location().parent_path() / "python";
|
const auto python_home = boost::dll::program_location().parent_path() / "python";
|
||||||
|
#ifdef _WIN32
|
||||||
|
const auto stdlib = python_home / "Lib";
|
||||||
|
#else
|
||||||
|
const auto stdlib = python_home / "lib" /
|
||||||
|
("python" + std::to_string(PY_MAJOR_VERSION) + "." + std::to_string(PY_MINOR_VERSION));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (boost::filesystem::exists(python_home)) {
|
// Only a real runtime: a stray python/ folder (packages a test left behind) is not a home.
|
||||||
|
if (boost::filesystem::exists(stdlib / "encodings")) {
|
||||||
const std::string home = python_home.string();
|
const std::string home = python_home.string();
|
||||||
const PyStatus status = PyConfig_SetBytesString(&config, &config.home, home.c_str());
|
const PyStatus status = PyConfig_SetBytesString(&config, &config.home, home.c_str());
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace {
|
|||||||
// before this destructor's shutdown() runs.
|
// before this destructor's shutdown() runs.
|
||||||
struct ScopedPluginManager
|
struct ScopedPluginManager
|
||||||
{
|
{
|
||||||
|
// Before initialize(): the interpreter creates {data_dir}/python/packages and {data_dir}/log,
|
||||||
|
// which would otherwise land in the working directory.
|
||||||
|
ScopedDataDir python_data_dir{"plugin-python"};
|
||||||
bool initialized = PluginManager::instance().initialize();
|
bool initialized = PluginManager::instance().initialize();
|
||||||
|
|
||||||
~ScopedPluginManager()
|
~ScopedPluginManager()
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace {
|
|||||||
// same as any other plugin.
|
// same as any other plugin.
|
||||||
struct ScopedManagerShutdown
|
struct ScopedManagerShutdown
|
||||||
{
|
{
|
||||||
|
// Before initialize(): the interpreter creates {data_dir}/python/packages and {data_dir}/log,
|
||||||
|
// which would otherwise land in the working directory.
|
||||||
|
ScopedDataDir python_data_dir{"plugin-python"};
|
||||||
bool initialized = PluginManager::instance().initialize();
|
bool initialized = PluginManager::instance().initialize();
|
||||||
|
|
||||||
~ScopedManagerShutdown()
|
~ScopedManagerShutdown()
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ namespace {
|
|||||||
// Declare this FIRST in a test so it is destroyed last.
|
// Declare this FIRST in a test so it is destroyed last.
|
||||||
struct ScopedPluginManager
|
struct ScopedPluginManager
|
||||||
{
|
{
|
||||||
|
// Before initialize(): the interpreter creates {data_dir}/python/packages and {data_dir}/log,
|
||||||
|
// which would otherwise land in the working directory.
|
||||||
|
ScopedDataDir python_data_dir{"plugin-python"};
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
ScopedPluginManager() { initialized = PluginManager::instance().initialize(); }
|
ScopedPluginManager() { initialized = PluginManager::instance().initialize(); }
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "plugin_test_utils.hpp"
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
|
|
||||||
@@ -21,6 +23,9 @@ namespace {
|
|||||||
// into Python unless PythonInterpreter::instance() reports initialized.
|
// into Python unless PythonInterpreter::instance() reports initialized.
|
||||||
struct ScopedPluginManager
|
struct ScopedPluginManager
|
||||||
{
|
{
|
||||||
|
// Before initialize(): the interpreter creates {data_dir}/python/packages and {data_dir}/log,
|
||||||
|
// which would otherwise land in the working directory.
|
||||||
|
ScopedDataDir python_data_dir{"plugin-python"};
|
||||||
bool initialized = PluginManager::instance().initialize();
|
bool initialized = PluginManager::instance().initialize();
|
||||||
|
|
||||||
~ScopedPluginManager()
|
~ScopedPluginManager()
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ namespace {
|
|||||||
|
|
||||||
struct ScopedPluginManager
|
struct ScopedPluginManager
|
||||||
{
|
{
|
||||||
|
// Before initialize(): the interpreter creates {data_dir}/python/packages and {data_dir}/log,
|
||||||
|
// which would otherwise land in the working directory.
|
||||||
|
ScopedDataDir python_data_dir{"plugin-python"};
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
ScopedPluginManager() { initialized = PluginManager::instance().initialize(); }
|
ScopedPluginManager() { initialized = PluginManager::instance().initialize(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user