From 3a5e7bf33a45e6f6c3b272544b2e1a112d68f657 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Tue, 19 Jun 2007 16:49:21 +0000 Subject: [PATCH] Restored PYTHONPATH in ppython --- direct/src/directbase/ppython.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 9a1ba8bd87..483752d9a9 100755 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -68,6 +68,13 @@ int main(int argc, char **argv) if (f==0) pathfail(); fclose(f); + // Set the PYTHONPATH + + char *pp = getenv("PYTHONPATH"); + if (pp) sprintf(ppbuf,"PYTHONPATH=%s;%s\\bin;%s",fnbuf,fnbuf,pp); + else sprintf(ppbuf,"PYTHONPATH=%s;%s\\bin",fnbuf,fnbuf); + putenv(ppbuf); + // Fetch the command line and trim the first word. char *cmdline = GetCommandLine(); @@ -171,6 +178,18 @@ int main(int argc, char **argv) if (strcmp(fnbuf + fnlen - srclen, LINK_SOURCE)) pathfail(); fnlen -= srclen; fnbuf[fnlen] = 0; + // See if we can find the 'direct' tree locally. + // If not, continue anyway. It may be possible to succeed. + + sprintf(ppbuf,"%s/direct/__init__.py",fnbuf); + FILE *f = fopen(ppbuf,"r"); + if (f) { + char *pp = getenv("PYTHONPATH"); + if (pp) sprintf(ppbuf,"PYTHONPATH=%s:%s/lib:%s",fnbuf,fnbuf,pp); + else sprintf(ppbuf,"PYTHONPATH=%s:%s/lib",fnbuf,fnbuf); + putenv(ppbuf); + } + // Calculate MODARGV modargc=0;