Back to index

python3.2  3.2.2
Classes | Functions | Variables
setup Namespace Reference

Classes

class  DocBuild
class  AHVDocInstall
class  PyBuildExt
class  PyBuildInstall
class  PyBuildInstallLib
class  PyBuildScripts

Functions

def buildDocsFromSource
 print "** Please unpack %s" % os.path.join(self.build_base, tarfile) print "** Unpack the files into %s" % self.build_html raise RuntimeError, "You need to unpack the docs manually"
def ensureHtml
def hackIndex
def hackFile
def hackHtml
def visit
def makeHelpIndex
def run
def mungeVersion
def main
def add_dir_to_list
def macosx_sdk_root
def is_macosx_sdk_path
def find_file
def find_library_file
def module_enabled
def find_module_file
def configure_ctypes_darwin
def configure_ctypes
def detect_ctypes

Variables

list ext_modules
string MAJOR_VERSION = '2.4'
string MINOR_VERSION = '2.4.1'
string DESTDIR = '/Applications/MacPython-%s/PythonIDE.app/Contents/Resources/English.lproj/PythonDocumentation'
string version = '%d.%d'
 import warnings warnings.filterwarnings("ignore",category=DeprecationWarning)
dictionary cmdclass = {'install_data':AHVDocInstall, 'build':DocBuild}
list data_files = ['dummy']
 r
tuple example_mod = Extension('example', sources = ['example.c'])
string description = "A sample extension module"
string __version__ = "$Revision$"
tuple COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
list disabled_module_list = []
string _BUILDDIR_COOKIE = "pybuilddir.txt"
tuple ext
 

Uncomment these lines if you want to play with xxmodule.c

ext = Extension('xx', ['xxmodule.c']) self.extensions.append(ext)
tuple ext_test
list ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
list ffi_h = ffi_inc[0]
tuple line = fp.readline()
 ffi_lib = None
string SUMMARY
string CLASSIFIERS
 use_system_libffi
string name = "test2to3"
string author = "Martin v. L÷wis"
string author_email = "python-dev@python.org"
string license = "PSF license"
list packages = ["test2to3"]
list scripts = ["maintest.py"]

Function Documentation

def setup.add_dir_to_list (   dirlist,
  dir 
)
Add the directory 'dir' to the list 'dirlist' (after any relative
directories) if:

1) 'dir' is not already in 'dirlist'
2) 'dir' actually exists, and is a directory.

Definition at line 30 of file setup.py.

00030 
00031 def add_dir_to_list(dirlist, dir):
00032     """Add the directory 'dir' to the list 'dirlist' (after any relative
00033     directories) if:
00034 
00035     1) 'dir' is not already in 'dirlist'
00036     2) 'dir' actually exists, and is a directory.
00037     """
00038     if dir is None or not os.path.isdir(dir) or dir in dirlist:
00039         return
00040     for i, path in enumerate(dirlist):
00041         if not os.path.isabs(path):
00042             dirlist.insert(i + 1, dir)
00043             return
00044     dirlist.insert(0, dir)

Here is the call graph for this function:

Here is the caller graph for this function:

def setup.buildDocsFromSource (   self)

print "** Please unpack %s" % os.path.join(self.build_base, tarfile) print "** Unpack the files into %s" % self.build_html raise RuntimeError, "You need to unpack the docs manually"

Definition at line 72 of file setup.py.

00072 
00073     def buildDocsFromSource(self):
00074         srcdir = '../../..'
00075         docdir = os.path.join(srcdir, 'Doc')
00076         htmldir = os.path.join(docdir, 'html')
00077         spawn(('make','--directory', docdir, 'html'), 1, self.verbose, self.dry_run)
00078         self.mkpath(self.build_html)
00079         copy_tree(htmldir, self.build_html)

Here is the call graph for this function:

def setup.configure_ctypes (   self,
  ext 
)

Definition at line 1646 of file setup.py.

01646 
01647     def configure_ctypes(self, ext):
01648         if not self.use_system_libffi:
01649             if sys.platform == 'darwin':
01650                 return self.configure_ctypes_darwin(ext)
01651 
01652             srcdir = sysconfig.get_config_var('srcdir')
01653             ffi_builddir = os.path.join(self.build_temp, 'libffi')
01654             ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
01655                                          '_ctypes', 'libffi'))
01656             ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py')
01657 
01658             from distutils.dep_util import newer_group
01659 
01660             config_sources = [os.path.join(ffi_srcdir, fname)
01661                               for fname in os.listdir(ffi_srcdir)
01662                               if os.path.isfile(os.path.join(ffi_srcdir, fname))]
01663             if self.force or newer_group(config_sources,
01664                                          ffi_configfile):
01665                 from distutils.dir_util import mkpath
01666                 mkpath(ffi_builddir)
01667                 config_args = []
01668 
01669                 # Pass empty CFLAGS because we'll just append the resulting
01670                 # CFLAGS to Python's; -g or -O2 is to be avoided.
01671                 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
01672                       % (ffi_builddir, ffi_srcdir, " ".join(config_args))
01673 
01674                 res = os.system(cmd)
01675                 if res or not os.path.exists(ffi_configfile):
01676                     print("Failed to configure _ctypes module")
01677                     return False
01678 
01679             fficonfig = {}
01680             with open(ffi_configfile) as f:
01681                 exec(f.read(), globals(), fficonfig)
01682 
01683             # Add .S (preprocessed assembly) to C compiler source extensions.
01684             self.compiler.src_extensions.append('.S')
01685 
01686             include_dirs = [os.path.join(ffi_builddir, 'include'),
01687                             ffi_builddir,
01688                             os.path.join(ffi_srcdir, 'src')]
01689             extra_compile_args = fficonfig['ffi_cflags'].split()
01690 
01691             ext.sources.extend(os.path.join(ffi_srcdir, f) for f in
01692                                fficonfig['ffi_sources'])
01693             ext.include_dirs.extend(include_dirs)
01694             ext.extra_compile_args.extend(extra_compile_args)
01695         return True

Here is the call graph for this function:

def setup.configure_ctypes_darwin (   self,
  ext 
)

Definition at line 1619 of file setup.py.

01619 
01620     def configure_ctypes_darwin(self, ext):
01621         # Darwin (OS X) uses preconfigured files, in
01622         # the Modules/_ctypes/libffi_osx directory.
01623         srcdir = sysconfig.get_config_var('srcdir')
01624         ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
01625                                                   '_ctypes', 'libffi_osx'))
01626         sources = [os.path.join(ffi_srcdir, p)
01627                    for p in ['ffi.c',
01628                              'x86/darwin64.S',
01629                              'x86/x86-darwin.S',
01630                              'x86/x86-ffi_darwin.c',
01631                              'x86/x86-ffi64.c',
01632                              'powerpc/ppc-darwin.S',
01633                              'powerpc/ppc-darwin_closure.S',
01634                              'powerpc/ppc-ffi_darwin.c',
01635                              'powerpc/ppc64-darwin_closure.S',
01636                              ]]
01637 
01638         # Add .S (preprocessed assembly) to C compiler source extensions.
01639         self.compiler.src_extensions.append('.S')
01640 
01641         include_dirs = [os.path.join(ffi_srcdir, 'include'),
01642                         os.path.join(ffi_srcdir, 'powerpc')]
01643         ext.include_dirs.extend(include_dirs)
01644         ext.sources.extend(sources)
01645         return True

Here is the call graph for this function:

def setup.detect_ctypes (   self,
  inc_dirs,
  lib_dirs 
)

Definition at line 1696 of file setup.py.

01696 
01697     def detect_ctypes(self, inc_dirs, lib_dirs):
01698         self.use_system_libffi = False
01699         include_dirs = []
01700         extra_compile_args = []
01701         extra_link_args = []
01702         sources = ['_ctypes/_ctypes.c',
01703                    '_ctypes/callbacks.c',
01704                    '_ctypes/callproc.c',
01705                    '_ctypes/stgdict.c',
01706                    '_ctypes/cfield.c']
01707         depends = ['_ctypes/ctypes.h']
01708 
01709         if sys.platform == 'darwin':
01710             sources.append('_ctypes/malloc_closure.c')
01711             sources.append('_ctypes/darwin/dlfcn_simple.c')
01712             extra_compile_args.append('-DMACOSX')
01713             include_dirs.append('_ctypes/darwin')
# XXX Is this still needed?
def setup.ensureHtml (   self)

Definition at line 80 of file setup.py.

00080 
00081     def ensureHtml(self):
00082         if not os.path.exists(self.build_html):
00083             if self.download:
00084                 self.downloadDocs()
00085             else:
00086                 self.buildDocsFromSource()

def setup.find_file (   filename,
  std_dirs,
  paths 
)
Searches for the directory where a given file is located,
and returns a possibly-empty list of additional directories, or None
if the file couldn't be found at all.

'filename' is the name of a file, such as readline.h or libcrypto.a.
'std_dirs' is the list of standard system directories; if the
    file is found in one of them, no additional directives are needed.
'paths' is a list of additional locations to check; if the file is
    found in one of them, the resulting list will contain the directory.

Definition at line 64 of file setup.py.

00064 
00065 def find_file(filename, std_dirs, paths):
00066     """Searches for the directory where a given file is located,
00067     and returns a possibly-empty list of additional directories, or None
00068     if the file couldn't be found at all.
00069 
00070     'filename' is the name of a file, such as readline.h or libcrypto.a.
00071     'std_dirs' is the list of standard system directories; if the
00072         file is found in one of them, no additional directives are needed.
00073     'paths' is a list of additional locations to check; if the file is
00074         found in one of them, the resulting list will contain the directory.
00075     """
00076     if sys.platform == 'darwin':
00077         # Honor the MacOSX SDK setting when one was specified.
00078         # An SDK is a directory with the same structure as a real
00079         # system, but with only header files and libraries.
00080         sysroot = macosx_sdk_root()
00081 
00082     # Check the standard locations
00083     for dir in std_dirs:
00084         f = os.path.join(dir, filename)
00085 
00086         if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
00087             f = os.path.join(sysroot, dir[1:], filename)
00088 
00089         if os.path.exists(f): return []
00090 
00091     # Check the additional directories
00092     for dir in paths:
00093         f = os.path.join(dir, filename)
00094 
00095         if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
00096             f = os.path.join(sysroot, dir[1:], filename)
00097 
00098         if os.path.exists(f):
00099             return [dir]
00100 
00101     # Not found anywhere
00102     return None

Here is the call graph for this function:

Here is the caller graph for this function:

def setup.find_library_file (   compiler,
  libname,
  std_dirs,
  paths 
)

Definition at line 103 of file setup.py.

00103 
00104 def find_library_file(compiler, libname, std_dirs, paths):
00105     result = compiler.find_library_file(std_dirs + paths, libname)
00106     if result is None:
00107         return None
00108 
00109     if sys.platform == 'darwin':
00110         sysroot = macosx_sdk_root()
00111 
00112     # Check whether the found file is in one of the standard directories
00113     dirname = os.path.dirname(result)
00114     for p in std_dirs:
00115         # Ensure path doesn't end with path separator
00116         p = p.rstrip(os.sep)
00117 
00118         if sys.platform == 'darwin' and is_macosx_sdk_path(p):
00119             if os.path.join(sysroot, p[1:]) == dirname:
00120                 return [ ]
00121 
00122         if p == dirname:
00123             return [ ]
00124 
00125     # Otherwise, it must have been in one of the additional directories,
00126     # so we have to figure out which one.
00127     for p in paths:
00128         # Ensure path doesn't end with path separator
00129         p = p.rstrip(os.sep)
00130 
00131         if sys.platform == 'darwin' and is_macosx_sdk_path(p):
00132             if os.path.join(sysroot, p[1:]) == dirname:
00133                 return [ p ]
00134 
00135         if p == dirname:
00136             return [p]
00137     else:
00138         assert False, "Internal error: Path not found in std_dirs or paths"

Here is the call graph for this function:

Here is the caller graph for this function:

def setup.find_module_file (   module,
  dirlist 
)
Find a module in a set of possible folders. If it is not found
return the unadorned filename

Definition at line 145 of file setup.py.

00145 
00146 def find_module_file(module, dirlist):
00147     """Find a module in a set of possible folders. If it is not found
00148     return the unadorned filename"""
00149     list = find_file(module, [], dirlist)
00150     if not list:
00151         return module
00152     if len(list) > 1:
00153         log.info("WARNING: multiple copies of %s found"%module)
00154     return os.path.join(list[0], module)

Here is the call graph for this function:

def setup.hackFile (   self,
  d,
  f 
)

Definition at line 95 of file setup.py.

00095 
00096     def hackFile(self,d,f):
00097         origPath = os.path.join(d,f)
00098         assert(origPath[:len(self.build_html)] == self.build_html)
00099         outPath = os.path.join(self.build_dest, d[len(self.build_html)+1:], f)
00100         (name, ext) = os.path.splitext(f)
00101         if os.path.isdir(origPath):
00102             self.mkpath(outPath)
00103         elif ext == '.html':
00104             if self.verbose: print('hacking %s to %s' % (origPath,outPath))
00105             hackedFile = file(outPath, 'w')
00106             origFile = file(origPath,'r')
00107             hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read()))
00108         else:
00109             copy_file(origPath, outPath)

Here is the call graph for this function:

def setup.hackHtml (   self)

Definition at line 110 of file setup.py.

00110 
00111     def hackHtml(self):
00112         self.r = re.compile('<dl><dd>')
00113         os.walk(self.build_html, self.visit, None)

def setup.hackIndex (   self)

Definition at line 87 of file setup.py.

00087 
00088     def hackIndex(self):
00089         ind_html = 'index.html'
00090         #print 'self.build_dest =', self.build_dest
00091         hackedIndex = file(os.path.join(self.build_dest, ind_html),'w')
00092         origIndex = file(os.path.join(self.build_html,ind_html))
00093         r = re.compile('<style type="text/css">.*</style>', re.DOTALL)
00094         hackedIndex.write(r.sub('<META NAME="AppleTitle" CONTENT="Python Documentation">',origIndex.read()))

Here is the call graph for this function:

def setup.is_macosx_sdk_path (   path)
Returns True if 'path' can be located in an OSX SDK

Definition at line 58 of file setup.py.

00058 
00059 def is_macosx_sdk_path(path):
00060     """
00061     Returns True if 'path' can be located in an OSX SDK
00062     """
00063     return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/')

Here is the caller graph for this function:

Return the directory of the current OSX SDK,
or '/' if no SDK was specified.

Definition at line 45 of file setup.py.

00045 
00046 def macosx_sdk_root():
00047     """
00048     Return the directory of the current OSX SDK,
00049     or '/' if no SDK was specified.
00050     """
00051     cflags = sysconfig.get_config_var('CFLAGS')
00052     m = re.search(r'-isysroot\s+(\S+)', cflags)
00053     if m is None:
00054         sysroot = '/'
00055     else:
00056         sysroot = m.group(1)
00057     return sysroot

Here is the call graph for this function:

Here is the caller graph for this function:

def setup.main ( void  )

Definition at line 202 of file setup.py.

00202 
00203 def main():
    # turn off warnings when deprecated modules are imported
def setup.makeHelpIndex (   self)

Definition at line 118 of file setup.py.

00118 
00119     def makeHelpIndex(self):
00120         app = '/Developer/Applications/Apple Help Indexing Tool.app'
00121         self.spawn('open', '-a', app , self.build_dest)
00122         print("Please wait until Apple Help Indexing Tool finishes before installing")

def setup.module_enabled (   extlist,
  modname 
)
Returns whether the module 'modname' is present in the list
of extensions 'extlist'.

Definition at line 139 of file setup.py.

00139 
00140 def module_enabled(extlist, modname):
00141     """Returns whether the module 'modname' is present in the list
00142     of extensions 'extlist'."""
00143     extlist = [ext for ext in extlist if ext.name == modname]
00144     return len(extlist)

Here is the caller graph for this function:

def setup.mungeVersion (   infile,
  outfile 
)

Definition at line 195 of file setup.py.

00195 
00196 def mungeVersion(infile, outfile):
00197     i = file(infile,'r')
00198     o = file(outfile,'w')
00199     o.write(re.sub('\$\(VERSION\)',sysconfig.get_config_var('VERSION'),i.read()))
00200     i.close()
00201     o.close()

Here is the call graph for this function:

def setup.run (   self)

Definition at line 144 of file setup.py.

00144 
00145     def run(self):
00146         self.ensure_finalized()
00147         self.mkpath(self.build_base)
00148         self.ensureHtml()
00149         if not os.path.isdir(self.build_html):
00150             raise RuntimeError("Can't find source folder for documentation.")
00151         self.mkpath(self.build_dest)
00152         if dep_util.newer(os.path.join(self.build_html,'index.html'), os.path.join(self.build_dest,'index.html')):
00153             self.mkpath(self.build_dest)
00154             self.hackHtml()
00155             self.hackIndex()
00156             self.makeHelpIndex()

def setup.visit (   self,
  dummy,
  dirname,
  filenames 
)

Definition at line 114 of file setup.py.

00114 
00115     def visit(self, dummy, dirname, filenames):
00116         for f in filenames:
00117             self.hackFile(dirname, f)

Here is the caller graph for this function:


Variable Documentation

string setup.__version__ = "$Revision$"

Definition at line 4 of file setup.py.

string setup._BUILDDIR_COOKIE = "pybuilddir.txt"

Definition at line 28 of file setup.py.

string setup.author = "Martin v. L÷wis"

Definition at line 18 of file setup.py.

string setup.author_email = "python-dev@python.org"

Definition at line 19 of file setup.py.

Initial value:
00001 """
00002 Development Status :: 6 - Mature
00003 License :: OSI Approved :: Python Software Foundation License
00004 Natural Language :: English
00005 Programming Language :: C
00006 Programming Language :: Python
00007 Topic :: Software Development
00008 """

Definition at line 1857 of file setup.py.

Definition at line 208 of file setup.py.

tuple setup.COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')

Definition at line 21 of file setup.py.

list setup.data_files = ['dummy']

Definition at line 209 of file setup.py.

string setup.description = "A sample extension module"

Definition at line 20 of file setup.py.

string setup.DESTDIR = '/Applications/MacPython-%s/PythonIDE.app/Contents/Resources/English.lproj/PythonDocumentation'

Definition at line 33 of file setup.py.

Definition at line 24 of file setup.py.

tuple setup.example_mod = Extension('example', sources = ['example.c'])

Definition at line 15 of file setup.py.

tuple setup.ext
Initial value:
00001 Extension('xxlimited', ['xxlimited.c'],
00002                             define_macros=[('Py_LIMITED_API', 1)])

Uncomment these lines if you want to play with xxmodule.c

ext = Extension('xx', ['xxmodule.c']) self.extensions.append(ext)

extra_link_args.extend(['-read_only_relocs', 'warning'])

Definition at line 1607 of file setup.py.

Initial value:
00001 [
00002          Extension("noddy", ["noddy.c"]),
00003          Extension("noddy2", ["noddy2.c"]),
00004          Extension("noddy3", ["noddy3.c"]),
00005          Extension("noddy4", ["noddy4.c"]),
00006          ]

Definition at line 3 of file setup.py.

Initial value:
00001 Extension('_ctypes_test',
00002                              sources=['_ctypes/_ctypes_test.c'])

Definition at line 1737 of file setup.py.

list setup.ffi_h = ffi_inc[0]

Definition at line 1753 of file setup.py.

tuple setup.ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]

Definition at line 1749 of file setup.py.

setup.ffi_lib = None

Definition at line 1762 of file setup.py.

Definition at line 20 of file setup.py.

tuple setup.line = fp.readline()

Definition at line 1756 of file setup.py.

Definition at line 31 of file setup.py.

Definition at line 32 of file setup.py.

string setup.name = "test2to3"

Definition at line 15 of file setup.py.

list setup.packages = ["test2to3"]

Definition at line 21 of file setup.py.

Definition at line 111 of file setup.py.

list setup.scripts = ["maintest.py"]

Definition at line 22 of file setup.py.

Initial value:
00001 """
00002 Python is an interpreted, interactive, object-oriented programming
00003 language. It is often compared to Tcl, Perl, Scheme or Java.
00004 
00005 Python combines remarkable power with very clear syntax. It has
00006 modules, classes, exceptions, very high level dynamic data types, and
00007 dynamic typing. There are interfaces to many system calls and
00008 libraries, as well as to various windowing systems (X11, Motif, Tk,
00009 Mac, MFC). New built-in modules are easily written in C or C++. Python
00010 is also usable as an extension language for applications that need a
00011 programmable interface.
00012 
00013 The Python implementation is portable: it runs on many brands of UNIX,
00014 on Windows, DOS, OS/2, Mac, Amiga... If your favorite system isn't
00015 listed here, it may still be supported, if there's a C compiler for
00016 it. Ask around on comp.lang.python -- or just try compiling Python
00017 yourself.
00018 """

Definition at line 1838 of file setup.py.

Definition at line 1697 of file setup.py.

string setup.version = '%d.%d'

import warnings warnings.filterwarnings("ignore",category=DeprecationWarning)

Definition at line 207 of file setup.py.