mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
find python26.zip and add it to PYTHONPATH
This commit is contained in:
parent
a9862a4450
commit
788244d5a8
@ -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
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "dtoolbase.h"
|
||||
#include "filename.h"
|
||||
#include "globPattern.h"
|
||||
#include "dSearchPath.h"
|
||||
#include "executionEnvironment.h"
|
||||
#include <stdlib.h>
|
||||
@ -27,6 +28,22 @@
|
||||
#include <windows.h>
|
||||
#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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user