From c073edb5ad493ba8a6175d9eae17660490aac33e Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 23 Feb 2005 21:58:07 +0000 Subject: [PATCH] Changing paths for D. Rose's proposed layout --- direct/src/directbase/ppython.cxx | 23 +++++----- direct/src/ffi/jGenPyCode.py | 71 ++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 237833fc73..f666817891 100755 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -6,7 +6,6 @@ // // PYTHONPATH // PATH -// PANDAROOT // // Note that 'genpycode' is just a slight variant of 'ppython': // @@ -69,11 +68,15 @@ int main(int argc, char **argv) fnlen -= srclen; fnbuf[fnlen] = 0; // Fetch the command line and trim the first word. - - char *args = GetCommandLine(); - char *firstspace = strchr(args,' '); - if (firstspace) args = firstspace+1; - else args=""; + + char *cmdline = GetCommandLine(); + char *args = cmdline; + bool inquote = false; + while (*args && ((*args != ' ')||(inquote))) { + if (*args == '"') inquote = !inquote; + args++; + } + while (*args==' ') args++; // Calculate MODCMD @@ -88,7 +91,7 @@ int main(int argc, char **argv) } } else sprintf(modcmd,"python %s",args); - // Set the PANDAROOT, PYTHONPATH and PATH + // Set the PYTHONPATH and PATH char *pp = getenv("PYTHONPATH"); if (pp) sprintf(ppbuf,"PYTHONPATH=%s;%s\\bin;%s\\lib;%s",fnbuf,fnbuf,fnbuf,pp); @@ -98,8 +101,6 @@ int main(int argc, char **argv) if (path) sprintf(pabuf,"PATH=%s\\bin;%s",fnbuf,path); else sprintf(pabuf,"PATH=%s\\bin",fnbuf); putenv(pabuf); - sprintf(prbuf,"PANDAROOT=%s",fnbuf); - putenv(prbuf); // Append LINK_TARGET to the file name. @@ -192,7 +193,7 @@ int main(int argc, char **argv) } } - // Set the PANDAROOT, PYTHONPATH and PATH + // Set the PYTHONPATH and PATH char *pp = getenv("PYTHONPATH"); if (pp) sprintf(ppbuf,"PYTHONPATH=%s:%s/lib:%s",fnbuf,fnbuf,pp); @@ -202,8 +203,6 @@ int main(int argc, char **argv) if (path) sprintf(pabuf,"PATH=%s/bin;%s",fnbuf,path); else sprintf(pabuf,"PATH=%s/bin",fnbuf); putenv(pabuf); - sprintf(prbuf,"PANDAROOT=%s",fnbuf); - putenv(prbuf); // Calculate MODARGV modargc=0; diff --git a/direct/src/ffi/jGenPyCode.py b/direct/src/ffi/jGenPyCode.py index 6f3475fd35..37bf846abd 100755 --- a/direct/src/ffi/jGenPyCode.py +++ b/direct/src/ffi/jGenPyCode.py @@ -9,33 +9,74 @@ # can be located appropriately. # # PYTHONPATH -# PANDAROOT # PATH +# LD_LIBRARY_PATH # ############################################################## import sys,os; -if (os.environ.has_key("PANDAROOT")==0): - print "jGenPyCode was not invoked correctly" - sys.exit(1) +############################################################## +# +# Locate the 'direct' tree and the 'pandac' tree. +# +############################################################## -pandaroot = os.environ["PANDAROOT"] -if (os.path.isdir(os.path.join(pandaroot,"direct","src"))): - directsrc=os.path.join(pandaroot,"direct","src") -elif (os.path.isdir(os.path.join(os.path.dirname(pandaroot),"direct","src"))): - directsrc=os.path.join(os.path.dirname(pandaroot),"direct","src") -else: - print "jGenPyCode cannot locate the 'direct' tree" - sys.exit(1) +DIRECT=None +PANDAC=None +for dir in sys.path: + if (DIRECT is None): + if os.path.exist(os.path.join(dir,"direct")): + DIRECT=os.path.join(dir,"direct") + if (PANDAC is None): + if (os.path.exist(os.path.join(dir,"pandac"))): + PANDAC=os.path.join(dir,"pandac") + +if (DIRECT is None): + sys.exit("Could not locate the 'direct' python modules") +if (PANDAC is None): + sys.exit("Could not locate the 'pandac' python modules") + +############################################################## +# +# Locate direct/src/extensions. +# +# It could be inside the direct tree. It may be underneath +# a 'src' subdirectory. Or, the direct tree may actually be +# a stub that points to the source tree. +# +############################################################## + +EXTENSIONS=None + +if (EXTENSIONS is None): + if os.path.isdir(os.path.join(DIRECT,"src","extensions")): + EXTENSIONS=os.path.join(DIRECT,"src","extensions") + +if (EXTENSIONS is None): + if os.path.isdir(os.path.join(DIRECT,"extensions")): + EXTENSIONS=os.path.join(DIRECT,"extensions") + +if (EXTENSIONS is None): + if os.path.isdir(os.path.join(DIRECT,"..","..","direct","src","extensions")): + EXTENSIONS=os.path.join(DIRECT,"..","..","direct","src","extensions") + +if (EXTENSIONS is None): + sys.exit("Could not locate direct/src/extensions") + +############################################################## +# +# Call genpycode with default paths. +# +############################################################## from direct.ffi import DoGenPyCode from direct.ffi import FFIConstants -DoGenPyCode.outputDir = os.path.join(pandaroot,"lib","pandac") -DoGenPyCode.extensionsDir = os.path.join(directsrc,"extensions") +DoGenPyCode.outputDir = PANDAC +DoGenPyCode.extensionsDir = EXTENSIONS DoGenPyCode.interrogateLib = r'libdtoolconfig' DoGenPyCode.codeLibs = ['libpandaexpress','libpanda','libpandaphysics','libpandafx','libdirect'] -DoGenPyCode.etcPath = [os.path.join(pandaroot,"etc")] +DoGenPyCode.etcPath = [os.path.join(PANDAC,"input")] #print "outputDir = ",DoGenPyCode.outputDir #print "extensionsDir = ",DoGenPyCode.extensionsDir