mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
more fixes to new genPyCode
This commit is contained in:
parent
8e460f7fea
commit
6eeb4f27e3
@ -1,5 +1,4 @@
|
|||||||
// This is the toplevel directory. It contains configure.in and other
|
// This is the toplevel directory for a package.
|
||||||
// stuff.
|
|
||||||
|
|
||||||
#define DIR_TYPE toplevel
|
#define DIR_TYPE toplevel
|
||||||
|
|
||||||
@ -8,3 +7,5 @@
|
|||||||
|
|
||||||
#define EXTRA_DIST \
|
#define EXTRA_DIST \
|
||||||
Sources.pp Config.pp Package.pp
|
Sources.pp Config.pp Package.pp
|
||||||
|
|
||||||
|
#define PYTHON_PACKAGE 1
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
"""This file defines the path to the Python files within this package.
|
|
||||||
There are two cases:
|
|
||||||
|
|
||||||
(1) This is a source tree being run interactively by a developer, in
|
|
||||||
which case the Python files are found in package/src/*/*.py. This
|
|
||||||
case also breaks down into two sub-cases: (1a) we are using the
|
|
||||||
ctattach tools, in which case we should look for the files in the
|
|
||||||
actual source directory according to the ctattach variables, or
|
|
||||||
(1b) we are not using the ctattach tools, in which case the files
|
|
||||||
are right where we expect them to be.
|
|
||||||
|
|
||||||
(2) This is an installed tree being run by an end-user, in which case
|
|
||||||
the Python files are found in package/*/*.py. In this case, this
|
|
||||||
file doesn't really need to be installed; an empty __init__.py
|
|
||||||
file to define the package would serve just as well. But the file
|
|
||||||
is crafted so that it will do no harm if it is installed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
package = 'DIRECT'
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
if os.getenv('CTPROJS'):
|
|
||||||
# Ok, this is case (1a): we are using the ctattach tools, are
|
|
||||||
# therefore will expect to find the source files in
|
|
||||||
# $(package)/src/*/*.py. Completely replace the search path with
|
|
||||||
# this path.
|
|
||||||
tree = os.getenv(package)
|
|
||||||
|
|
||||||
if not tree:
|
|
||||||
raise StandardError, 'CTPROJS is defined, but $%s is not defined!' % (package)
|
|
||||||
__path__[0] = os.path.join(tree, 'src')
|
|
||||||
|
|
||||||
else:
|
|
||||||
# We are not using the ctattach tools.
|
|
||||||
srcDir = os.path.join(__path__[0], 'src')
|
|
||||||
if os.path.isdir(srcDir):
|
|
||||||
# The source directory exists; therefore, we are in case (1b).
|
|
||||||
__path__[0] = srcDir
|
|
||||||
|
|
||||||
else:
|
|
||||||
# The source directory does not exist, so we must be in case
|
|
||||||
# (2). Leave well enough alone.
|
|
||||||
pass
|
|
||||||
|
|
0
direct/src/cluster/Sources.pp
Normal file
0
direct/src/cluster/Sources.pp
Normal file
0
direct/src/directdevices/Sources.pp
Normal file
0
direct/src/directdevices/Sources.pp
Normal file
0
direct/src/directnotify/Sources.pp
Normal file
0
direct/src/directnotify/Sources.pp
Normal file
0
direct/src/directtools/Sources.pp
Normal file
0
direct/src/directtools/Sources.pp
Normal file
0
direct/src/directutil/Sources.pp
Normal file
0
direct/src/directutil/Sources.pp
Normal file
@ -104,7 +104,7 @@ def doGetopts():
|
|||||||
elif (flag == '-n'):
|
elif (flag == '-n'):
|
||||||
doSqueeze = False
|
doSqueeze = False
|
||||||
elif (flag in ['-g', '-t', '-p', '-o']):
|
elif (flag in ['-g', '-t', '-p', '-o']):
|
||||||
FFIConstants.notify.warning("option is deprecated: %s" % (flag))
|
FFIConstants.notify.debug("option is deprecated: %s" % (flag))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
FFIConstants.notify.error('illegal option: ' + flag)
|
FFIConstants.notify.error('illegal option: ' + flag)
|
||||||
|
@ -33,7 +33,7 @@ python $[osfilename $[install_bin_dir]/genPyCode.py] %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|||||||
|
|
||||||
#output genPyCode
|
#output genPyCode
|
||||||
$[hash]! /bin/sh
|
$[hash]! /bin/sh
|
||||||
ppython '$[osfilename $[install_bin_dir]/genPyCode.py]' "$@"
|
python '$[osfilename $[install_bin_dir]/genPyCode.py]' "$@"
|
||||||
#end genPyCode
|
#end genPyCode
|
||||||
|
|
||||||
#endif // Win32
|
#endif // Win32
|
||||||
@ -49,6 +49,26 @@ import glob
|
|||||||
# This script was generated while the user was using the ctattach
|
# This script was generated while the user was using the ctattach
|
||||||
# tools. That had better still be the case.
|
# tools. That had better still be the case.
|
||||||
|
|
||||||
|
def deCygwinify(path):
|
||||||
|
if os.name in ['nt'] and path[0] == '/':
|
||||||
|
# On Windows, we may need to convert from a Cygwin-style path
|
||||||
|
# to a native Windows path.
|
||||||
|
|
||||||
|
# Check for a case like /i/ or /p/: this converts
|
||||||
|
# to i:/ or p:/.
|
||||||
|
|
||||||
|
dirs = path.split('/')
|
||||||
|
if len(dirs) > 2 and len(dirs[1]) == 1:
|
||||||
|
path = '%s:\%s' % (dirs[1], '\\'.join(dirs[2:]))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Otherwise, prepend $PANDA_ROOT and flip the slashes.
|
||||||
|
pandaRoot = os.getenv('PANDA_ROOT')
|
||||||
|
if pandaRoot:
|
||||||
|
path = os.path.normpath(pandaRoot + path)
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
ctprojs = os.getenv('CTPROJS')
|
ctprojs = os.getenv('CTPROJS')
|
||||||
if not ctprojs:
|
if not ctprojs:
|
||||||
print "You are no longer attached to any trees!"
|
print "You are no longer attached to any trees!"
|
||||||
@ -59,13 +79,15 @@ if not directDir:
|
|||||||
print "You are not attached to DIRECT!"
|
print "You are not attached to DIRECT!"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Make sure that direct/src/showbase/sitecustomize.py gets loaded.
|
directDir = deCygwinify(directDir)
|
||||||
|
|
||||||
|
# Make sure that direct.showbase.FindCtaPaths gets imported.
|
||||||
parent, base = os.path.split(directDir)
|
parent, base = os.path.split(directDir)
|
||||||
|
|
||||||
if parent not in sys.path:
|
if parent not in sys.path:
|
||||||
sys.path.append(parent)
|
sys.path.append(parent)
|
||||||
|
|
||||||
import direct.showbase.sitecustomize
|
import direct.showbase.FindCtaPaths
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -105,6 +127,7 @@ packages.reverse()
|
|||||||
for package in packages:
|
for package in packages:
|
||||||
packageDir = os.getenv(package)
|
packageDir = os.getenv(package)
|
||||||
if packageDir:
|
if packageDir:
|
||||||
|
packageDir = deCygwinify(packageDir)
|
||||||
etcDir = os.path.join(packageDir, 'etc')
|
etcDir = os.path.join(packageDir, 'etc')
|
||||||
try:
|
try:
|
||||||
inFiles = glob.glob(os.path.join(etcDir, '*.in'))
|
inFiles = glob.glob(os.path.join(etcDir, '*.in'))
|
||||||
@ -113,7 +136,7 @@ for package in packages:
|
|||||||
if inFiles:
|
if inFiles:
|
||||||
DoGenPyCode.etcPath.append(etcDir)
|
DoGenPyCode.etcPath.append(etcDir)
|
||||||
|
|
||||||
if package not in ['DTOOL', 'DIRECT', 'PANDA']:
|
if package not in ['WINTOOLS', 'DTOOL', 'DIRECT', 'PANDA']:
|
||||||
libDir = os.path.join(packageDir, 'lib')
|
libDir = os.path.join(packageDir, 'lib')
|
||||||
try:
|
try:
|
||||||
files = os.listdir(libDir)
|
files = os.listdir(libDir)
|
||||||
|
0
direct/src/fsm/Sources.pp
Normal file
0
direct/src/fsm/Sources.pp
Normal file
0
direct/src/gui/Sources.pp
Normal file
0
direct/src/gui/Sources.pp
Normal file
0
direct/src/particles/Sources.pp
Normal file
0
direct/src/particles/Sources.pp
Normal file
0
direct/src/pyinst/Sources.pp
Normal file
0
direct/src/pyinst/Sources.pp
Normal file
98
direct/src/showbase/FindCtaPaths.py
Executable file
98
direct/src/showbase/FindCtaPaths.py
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
"""This module is used only by the VR Studio programmers who are using
|
||||||
|
the ctattach tools. It is imported before any other package, and its
|
||||||
|
job is to figure out the correct paths to each of the packages.
|
||||||
|
|
||||||
|
This module is not needed if you are not using ctattach; in this case
|
||||||
|
all of the Panda packages will be collected under a common directory,
|
||||||
|
which you will presumably have already on your PYTHONPATH. """
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def deCygwinify(path):
|
||||||
|
if os.name in ['nt'] and path[0] == '/':
|
||||||
|
# On Windows, we may need to convert from a Cygwin-style path
|
||||||
|
# to a native Windows path.
|
||||||
|
|
||||||
|
# Check for a case like /i/ or /p/: this converts
|
||||||
|
# to i:\ or p:\.
|
||||||
|
|
||||||
|
dirs = path.split('/')
|
||||||
|
if len(dirs) > 2 and len(dirs[1]) == 1:
|
||||||
|
path = '%s:\%s' % (dirs[1], '\\'.join(dirs[2:]))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Otherwise, prepend $PANDA_ROOT and flip the slashes.
|
||||||
|
pandaRoot = os.getenv('PANDA_ROOT')
|
||||||
|
if pandaRoot:
|
||||||
|
path = os.path.normpath(pandaRoot + path)
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
|
def getPaths():
|
||||||
|
"""
|
||||||
|
Add to sys.path the appropriate director(ies) to search for the
|
||||||
|
various Panda projects. Typically, these will all be in the same
|
||||||
|
directory (which is presumably already on sys.path), but if the VR
|
||||||
|
Studio ctattach tools are in use they could be scattered around in
|
||||||
|
several places.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ctprojs = os.getenv("CTPROJS")
|
||||||
|
if ctprojs:
|
||||||
|
# The CTPROJS environment variable is defined. We must be
|
||||||
|
# using the ctattach tools. In this case, we need to figure
|
||||||
|
# out the location of each of the separate trees, and put the
|
||||||
|
# parent directory of each one on sys.path. In many cases,
|
||||||
|
# these will all be siblings, so we filter out duplicate
|
||||||
|
# parent directories.
|
||||||
|
|
||||||
|
print 'Appending to sys.path based on $CTPROJS:'
|
||||||
|
|
||||||
|
# First, get the list of packages, then reverse the list to
|
||||||
|
# put it in ctattach order. (The reversal may not matter too
|
||||||
|
# much these days, but let's be as correct as we can be.)
|
||||||
|
packages = []
|
||||||
|
for proj in ctprojs.split():
|
||||||
|
projName = proj.split(':')[0]
|
||||||
|
packages.append(projName)
|
||||||
|
packages.reverse()
|
||||||
|
|
||||||
|
# Now walk through the packages and figure out the parent of
|
||||||
|
# each referenced directory.
|
||||||
|
|
||||||
|
parents = []
|
||||||
|
for package in packages:
|
||||||
|
tree = os.getenv(package)
|
||||||
|
if not tree:
|
||||||
|
print " CTPROJS contains %s, but $%s is not defined." % (package, package)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
tree = deCygwinify(tree)
|
||||||
|
|
||||||
|
parent, base = os.path.split(tree)
|
||||||
|
if base != package.lower():
|
||||||
|
print " Warning: $%s refers to a directory named %s (instead of %s)" % (package, base, package.lower())
|
||||||
|
|
||||||
|
if parent not in parents:
|
||||||
|
parents.append(parent)
|
||||||
|
|
||||||
|
|
||||||
|
# We also put tree/lib on sys.path by hand, because we
|
||||||
|
# will need to load up the generated C++ modules that got
|
||||||
|
# put there. Also, we will find the output of genPyCode
|
||||||
|
# in $DIRECT/lib/pandac.
|
||||||
|
libdir = os.path.join(tree, 'lib')
|
||||||
|
if os.path.isdir(libdir):
|
||||||
|
if libdir not in sys.path:
|
||||||
|
sys.path.append(libdir)
|
||||||
|
|
||||||
|
|
||||||
|
# Now the result goes onto sys.path.
|
||||||
|
for parent in parents:
|
||||||
|
print " %s" % (parent)
|
||||||
|
if parent not in sys.path:
|
||||||
|
sys.path.append(parent)
|
||||||
|
|
||||||
|
|
||||||
|
getPaths()
|
@ -1,160 +1,37 @@
|
|||||||
|
"""This is a VR Studio custom script to make sure sys.path is set up
|
||||||
|
properly from the ctattach tools. It's not needed if you aren't using
|
||||||
|
ctattach, and its use is even somewhat deprecated for the VR Studio."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import glob
|
|
||||||
|
|
||||||
print 'Site customize for Panda:'
|
def deCygwinify(path):
|
||||||
|
if os.name in ['nt'] and path[0] == '/':
|
||||||
|
# On Windows, we may need to convert from a Cygwin-style path
|
||||||
|
# to a native Windows path.
|
||||||
|
|
||||||
|
# Check for a case like /i/ or /p/: this converts
|
||||||
|
# to I:/ or P:/.
|
||||||
|
|
||||||
def readpth(tree, fullname):
|
dirs = path.split('/')
|
||||||
#print "readpth(tree=%s, fullname=%s)" % (tree, fullname)
|
if len(dirs) > 2 and len(dirs[1]) == 1:
|
||||||
try:
|
path = '%s:\%s' % (dirs[1], '\\'.join(dirs[2:]))
|
||||||
f = open(fullname)
|
|
||||||
print ' Appending paths in ' + fullname
|
|
||||||
except IOError:
|
|
||||||
print ' IOError Appending paths in ' + fullname
|
|
||||||
return
|
|
||||||
|
|
||||||
while 1:
|
|
||||||
dir = f.readline()
|
|
||||||
if not dir:
|
|
||||||
break
|
|
||||||
if dir[0] == '#':
|
|
||||||
continue
|
|
||||||
if dir[-1] == '\n':
|
|
||||||
dir = dir[:-1]
|
|
||||||
dir = os.path.join(tree, dir)
|
|
||||||
if dir not in sys.path and os.path.exists(dir):
|
|
||||||
sys.path = [dir] + sys.path
|
|
||||||
|
|
||||||
def addpackage(package):
|
|
||||||
"""
|
|
||||||
Look in this package name for the file $PACKAGE/etc/package.pth
|
|
||||||
which contains paths that we want prepended to sys.path
|
|
||||||
There should be one relative pathname per line (relative to $PACKAGE)
|
|
||||||
comments and empty lines are ok
|
|
||||||
"""
|
|
||||||
tree = os.getenv(package)
|
|
||||||
if tree == None:
|
|
||||||
print " $%s is not defined." % (package,)
|
|
||||||
return
|
|
||||||
|
|
||||||
lowerPackage = package.lower()
|
|
||||||
fullname = os.path.join(tree, 'etc', lowerPackage + '.pth')
|
|
||||||
|
|
||||||
readpth(tree, fullname)
|
|
||||||
|
|
||||||
def getPackages():
|
|
||||||
"""
|
|
||||||
Find all the packages on your ctprojs variable and parse them
|
|
||||||
to extract the tree name from the long details like this:
|
|
||||||
TOONTOWN:default DIRECT:default PANDA:personal DTOOL:install
|
|
||||||
Returns a list of the packages as strings
|
|
||||||
Note: the ctprojs are reversed to put them in the order of attachment.
|
|
||||||
"""
|
|
||||||
ctprojs = os.getenv("CTPROJS")
|
|
||||||
if ctprojs == None:
|
|
||||||
# The CTPROJS environment variable isn't defined. Assume
|
|
||||||
# we're running from the directory above all of the source
|
|
||||||
# trees; look within these directories for the *.pth files.
|
|
||||||
|
|
||||||
# If PLAYER is defined, use that as the root; otherwise, use
|
|
||||||
# the current directory.
|
|
||||||
player = os.getenv("PLAYER")
|
|
||||||
if player == None:
|
|
||||||
print ' Appending paths based on current working directory.'
|
|
||||||
searchstr = os.path.join('*', 'src', 'configfiles', '*.pth')
|
|
||||||
else:
|
else:
|
||||||
print ' Appending paths based on $PLAYER'
|
# Otherwise, prepend $PANDA_ROOT and flip the slashes.
|
||||||
searchstr = os.path.join(player, '*', 'src', 'configfiles', '*.pth')
|
pandaRoot = os.getenv('PANDA_ROOT')
|
||||||
|
if pandaRoot:
|
||||||
filenames = glob.glob(searchstr)
|
path = os.path.normpath(pandaRoot + path)
|
||||||
if len(filenames) == 0:
|
|
||||||
print ''
|
|
||||||
print ' Warning: no files found matching %s.' % (searchstr)
|
|
||||||
print ' Check $PLAYER, or your starting directory.'
|
|
||||||
print ''
|
|
||||||
|
|
||||||
for filename in filenames:
|
|
||||||
tree = os.path.dirname(os.path.dirname(os.path.dirname(filename)))
|
|
||||||
readpth(tree, filename)
|
|
||||||
|
|
||||||
else:
|
return path
|
||||||
# The CTPROJS environment variable *is* defined. We must be
|
|
||||||
# using the ctattach tools; get the *.pth files from the set
|
|
||||||
# of attached trees.
|
|
||||||
print ' Appending paths based on $CTPROJS'
|
|
||||||
packages = []
|
|
||||||
|
|
||||||
for proj in ctprojs.split():
|
if os.getenv('CTPROJS'):
|
||||||
projName = proj.split(':')[0]
|
tree = os.getenv('DIRECT')
|
||||||
packages.append(projName)
|
if not tree:
|
||||||
packages.reverse()
|
raise StandardError,'CTPROJS is defined, but you are not attached to DIRECT!'
|
||||||
|
tree = deCygwinify(tree)
|
||||||
for package in packages:
|
parent, base = os.path.split(tree)
|
||||||
addpackage(package)
|
if parent not in sys.path:
|
||||||
|
sys.path.append(parent)
|
||||||
|
|
||||||
def getPath():
|
|
||||||
"""
|
|
||||||
Add to sys.path the appropriate director(ies) to search for the
|
|
||||||
various Panda projects. Typically, these will all be in the same
|
|
||||||
directory (which is presumably already on sys.path), but if the VR
|
|
||||||
Studio ctattach tools are in use they could be scattered around in
|
|
||||||
several places.
|
|
||||||
"""
|
|
||||||
|
|
||||||
ctprojs = os.getenv("CTPROJS")
|
|
||||||
if ctprojs:
|
|
||||||
# The CTPROJS environment variable is defined. We must be
|
|
||||||
# using the ctattach tools. In this case, we need to figure
|
|
||||||
# out the location of each of the separate trees, and put the
|
|
||||||
# parent directory of each one on sys.path. In many cases,
|
|
||||||
# these will all be siblings, so we filter out duplicate
|
|
||||||
# parent directories.
|
|
||||||
|
|
||||||
print ' Appending to sys.path based on $CTPROJS:'
|
|
||||||
|
|
||||||
# First, get the list of packages, then reverse the list to
|
|
||||||
# put it in ctattach order. (The reversal may not matter too
|
|
||||||
# much these days, but let's be as correct as we can be.)
|
|
||||||
packages = []
|
|
||||||
for proj in ctprojs.split():
|
|
||||||
projName = proj.split(':')[0]
|
|
||||||
packages.append(projName)
|
|
||||||
packages.reverse()
|
|
||||||
|
|
||||||
# Now walk through the packages and figure out the parent of
|
|
||||||
# each referenced directory.
|
|
||||||
|
|
||||||
parents = []
|
|
||||||
for package in packages:
|
|
||||||
tree = os.getenv(package)
|
|
||||||
if tree == None:
|
|
||||||
print " CTPROJS contains %s, but $%s is not defined." % (package, package)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
parent, base = os.path.split(tree)
|
|
||||||
if base != package.lower():
|
|
||||||
print " Warning: $%s refers to a directory named %s (instead of %s)" % (package, base, package.lower())
|
|
||||||
|
|
||||||
if parent not in parents:
|
|
||||||
parents.append(parent)
|
|
||||||
|
|
||||||
|
|
||||||
# We also put tree/lib on sys.path by hand, because we
|
|
||||||
# will need to load up the generated C++ modules that got
|
|
||||||
# put there. Also, we will find the output of genPyCode
|
|
||||||
# in $DIRECT/lib/pandac.
|
|
||||||
libdir = os.path.join(tree, 'lib')
|
|
||||||
if os.path.isdir(libdir):
|
|
||||||
sys.path.append(libdir)
|
|
||||||
|
|
||||||
|
|
||||||
# Now the result goes onto sys.path.
|
|
||||||
for parent in parents:
|
|
||||||
print " %s" % (parent)
|
|
||||||
sys.path.append(parent)
|
|
||||||
|
|
||||||
|
import direct.showbase.FindCtaPaths
|
||||||
#getPackages()
|
|
||||||
getPath()
|
|
||||||
|
0
direct/src/showutil/Sources.pp
Normal file
0
direct/src/showutil/Sources.pp
Normal file
0
direct/src/task/Sources.pp
Normal file
0
direct/src/task/Sources.pp
Normal file
Loading…
x
Reference in New Issue
Block a user