Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesneimog committed Nov 30, 2024
1 parent f362131 commit 9ac4cab
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Resources/Pd/pd4web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Pd4Web {
static bool pd4web_terminal(Pd4Web *x, std::string cmd, bool detached, bool sucessMsg,
bool showMessage, bool clearNewline);

// ─────────────────────────────────────
#if _WIN32
std::string pd4web_pyexe(Pd4Web *x) {
// Get the current user's home directory
Expand All @@ -73,23 +74,28 @@ std::string pd4web_pyexe(Pd4Web *x) {
}

// Construct the base path
std::filesystem::path basePath = std::string(userProfile);
basePath /= "AppData\\Local\\Programs\\Python";
std::filesystem::path basePath =
std::string(userProfile) + "\\AppData\\Local\\Programs\\Python";

// Check if the directory exists
if (!std::filesystem::exists(basePath)) {
pd_error(x, "[pd4web] Python directory not found at %s", basePath.string().c_str());
return "";
}

// Iterate through the directories in the base path
for (const auto &entry : std::filesystem::directory_iterator(basePath)) {
if (entry.is_directory()) {
std::filesystem::path pythonPath = entry.path() / "python.exe";
std::filesystem::path pythonPath =
entry.path() / "python.exe"; // Correct path concatenation
if (std::filesystem::exists(pythonPath)) {
post("[pd4web] Python executable found at %s", pythonPath.string().c_str());
return pythonPath.string();
}
}
}

pd_error(x, "[pd4web] Python executable not found");
return "";
}
#endif
Expand Down Expand Up @@ -666,6 +672,12 @@ static void *pd4web_new(t_symbol *s, int argc, t_atom *argv) {
x->pip = "\"" + x->objRoot + "\\.venv\\Scripts\\pip.exe\"";
x->python = "\"" + x->objRoot + "\\.venv\\Scripts\\python.exe\"";
x->pd4web = "\"" + x->objRoot + "\\.venv\\Scripts\\pd4web.exe\"";

// replace all / with \\
std::replace(x->pip.begin(), x->pip.end(), '/', '\\');
std::replace(x->python.begin(), x->python.end(), '/', '\\');
std::replace(x->pd4web.begin(), x->pd4web.end(), '/', '\\');

#elif defined(__APPLE__)
std::string PATHS = "PATH=" + x->objRoot + "/.venv/bin:/usr/local/bin:/usr/bin:/bin";
putenv((char *)PATHS.c_str());
Expand Down

0 comments on commit 9ac4cab

Please sign in to comment.