From c2a5b08de528269b5ec0ac0c1923197a9c08e456 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 28 Dec 2019 20:58:13 +0100 Subject: [PATCH] mayapath: fix maya tools when running from pip installation Fixes #709 --- pandatool/src/mayaprogs/mayapath.cxx | 32 ++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index d64f4c2ac5..1f42d359ee 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -195,26 +195,22 @@ int main(int argc, char *argv[]) { // First, get the command line and append _bin, so we will actually run // maya2egg_bin.exe, egg2maya_bin.exe, etc. - Filename command = Filename::from_os_specific(argv[0]); - if (!command.is_fully_qualified()) { - DSearchPath path; - path.append_path(ExecutionEnvironment::get_environment_variable("PATH")); -#ifdef _WIN32 - command.set_extension("exe"); -#endif - command.resolve_filename(path); + Filename command = ExecutionEnvironment::get_binary_name(); + + if (command.empty() || command == "unknown" || !command.exists()) { + command = Filename::from_os_specific(argv[0]); + + if (!command.is_fully_qualified()) { + DSearchPath path; + path.append_path(ExecutionEnvironment::get_environment_variable("PATH")); + #ifdef _WIN32 + command.set_extension("exe"); + #endif + command.resolve_filename(path); + } } -#ifdef _WIN32 - if (command.get_extension() == "exe") { - command.set_extension(""); - } -#endif - - command = command.get_fullpath() + string("_bin"); -#ifdef _WIN32 - command.set_extension("exe"); -#endif + command.set_basename_wo_extension(command.get_basename_wo_extension() + "_bin"); string os_command = command.to_os_specific(); // First start with $PANDA_MAYA_LOCATION. If it is set, it overrides