diff --git a/pandatool/src/mayaprogs/Sources.pp b/pandatool/src/mayaprogs/Sources.pp index e9dc8fa979..aeb90a1aa0 100644 --- a/pandatool/src/mayaprogs/Sources.pp +++ b/pandatool/src/mayaprogs/Sources.pp @@ -3,7 +3,7 @@ #begin bin_target #define TARGET maya2egg #define OTHER_LIBS \ - dtoolbase:c dtoolutil:c dtool:m + dtoolbase:c dtoolutil:c dtool:m prc:c dtoolconfig:m #define SOURCES \ mayapath.cxx #end bin_target @@ -11,7 +11,7 @@ #begin bin_target #define TARGET maya2egg_server #define OTHER_LIBS \ - dtoolbase:c dtoolutil:c dtool:m + dtoolbase:c dtoolutil:c dtool:m prc:c dtoolconfig:m #define SOURCES \ mayapath.cxx #end bin_target @@ -82,7 +82,7 @@ #begin bin_target #define TARGET egg2maya #define OTHER_LIBS \ - dtoolbase:c dtoolutil:c dtool:m + dtoolbase:c dtoolutil:c dtool:m prc:c dtoolconfig:m #define SOURCES \ mayapath.cxx #end bin_target @@ -112,7 +112,7 @@ #begin bin_target #define TARGET mayacopy #define OTHER_LIBS \ - dtoolbase:c dtoolutil:c dtool:m + dtoolbase:c dtoolutil:c dtool:m prc:c dtoolconfig:m #define SOURCES \ mayapath.cxx #end bin_target diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index cfda657dc2..2e1cd1b8f8 100755 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -18,6 +18,7 @@ #include "dtoolbase.h" #include "filename.h" +#include "globPattern.h" #include "dSearchPath.h" #include "executionEnvironment.h" #include @@ -27,6 +28,22 @@ #include #endif +// Searches for python26.zip or whatever version it is. +Filename +find_pyzip(const Filename &maya_location) { + // This is where python26.zip appears on Windows. Should it be in + // other locations on other platforms? + Filename dirname(maya_location, "bin"); + + vector_string results; + GlobPattern glob("python*.zip"); + if (glob.match_files(results, dirname) != 0) { + return Filename(dirname, results[0]); + } + + return Filename(); +} + int main(int argc, char *argv[]) { // First, get the command line and append _bin, so we will actually @@ -95,6 +112,12 @@ main(int argc, char *argv[]) { putenv(putenv_cstr); } +#ifdef WIN32 + string sep = ";"; +#else + string sep = ":"; +#endif + // Now set PYTHONHOME & PYTHONPATH. Maya2008 requires this to be // set and pointing within $MAYA_LOCATION, or it might get itself // confused with another Python installation (e.g. Panda's). @@ -107,6 +130,19 @@ main(int argc, char *argv[]) { } { string putenv_str = "PYTHONPATH=" + python.to_os_specific(); + + Filename pyzip = find_pyzip(maya_location); + if (!pyzip.empty() && pyzip.exists()) { + putenv_str += sep; + putenv_str += pyzip.to_os_specific(); + } + + Filename site_packages(python, "lib/site-packages"); + if (site_packages.is_directory()) { + putenv_str += sep; + putenv_str += site_packages.to_os_specific(); + } + char *putenv_cstr = strdup(putenv_str.c_str()); putenv(putenv_cstr); } @@ -119,11 +155,6 @@ main(int argc, char *argv[]) { if (path == NULL) { path = ""; } -#ifdef WIN32 - string sep = ";"; -#else - string sep = ":"; -#endif string putenv_str = "PATH=" + bin.to_os_specific() + sep + path; char *putenv_cstr = strdup(putenv_str.c_str()); putenv(putenv_cstr);