setup.py :  » Language-Interface » Pyana » Pyana-0.9.2 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » Pyana 
Pyana » Pyana 0.9.2 » setup.py
#!/usr/bin/env python 
 
# Copyright (c) 2001-2004 Mike Hostetler and Brian Quinlan
# All rights reserved. 
# See LICENSE.txt for details.
 
from distutils.core import setup,Extension
import sys 
import os

untestedPlatformWarning = '''"%s" is an untested system type. Attempting to build with "%s" 
defined (this probably won't work). Please file a bug report at 
http://sourceforge.net/tracker/?group_id=28142&atid=392469 
explaining what system you are attemping to build on and what 
went wrong.''' 
 
def setPlatformDefines(defines):
    if sys.platform.find('sunos') != -1: 
        defines.append(('SOLARIS',None)) 
    elif sys.platform.find('linux') != -1: 
        defines.append(('LINUX',None))
    elif sys.platform.find('darwin') != -1:
        defines.append(('DARWIN',None))   
    elif sys.platform.startswith('win32'): 
        defines.append(('WIN32',None)) 
    else: 
        print untestedPlatformWarning % (sys.platform, sys.platform.upper()) 
        defines.append((sys.platform.upper(), None)) 
 
def getXercesIncludePath(xercesCRoot):
    # correct path in source distribution
    xercesCInclude = os.path.join(xercesCRoot, 'include')
    print 'Checking for Xerces include path as %r...' % xercesCInclude,
    
    if os.path.isdir(xercesCInclude):
        print 'found'
    else:
        print 'not found'

        # correct binary distribution
        xercesCInclude = os.path.join(xercesCRoot, 'src')
        print 'Checking for Xerces include path as %r...' % xercesCInclude,
        
        if os.path.isdir(xercesCInclude):
            print 'found'
        else:
            print 'not found'
            print 'Fatal error: Xerces include directory could not be found.'
            sys.exit(1)
    return xercesCInclude

if sys.platform.startswith('win32'): 
    def getXercesLibraryPath(xercesCRoot):
        if sys.version_info >= (2,4):
            # by default Python 2.4 is compiled with Visual Studio 7
            xercesCLibPath = os.path.join(xercesCRoot, 'Build\Win32\VC7\Release')
        else:
            xercesCLibPath = os.path.join(xercesCRoot, 'Build\Win32\VC6\Release')
            
        print 'Checking for Xerces library path as %r...' % xercesCLibPath,
        
        if os.path.isdir(xercesCLibPath):
            print 'found'
        else:
            print 'not found'
            print 'Fatal error: Xerces library directory could not be found.'
            sys.exit(1)
        return xercesCLibPath
else:
    def getXercesLibraryPath(xercesCRoot):
        xercesCLibraryPath = os.path.join(xercesCRoot, 'lib')
        print 'Checking for Xerces library path as %r...' % xercesCLibraryPath,
        
        if os.path.isdir(xercesCLibraryPath):
            print 'found'
        else:
            print 'not found'
    
            print 'Fatal error: Xerces library directory could not be found.'
            sys.exit(1)
        return xercesCLibraryPath
        
def setXercesVariables(include_dirs, library_dirs, defines, libraries, data_files):
    if sys.platform.startswith('win32'):
        libraries.append('xerces-c_2')
    else:
        libraries.append('xerces-c')

    print 'Checking for "XERCESCROOT" environment variable...',
    
    if os.environ.has_key('XERCESCROOT'): 
        xercesCRoot = os.environ['XERCESCROOT']
        print 'found'
    else:
        print 'not found'
        xercesCRoot = os.path.join('..', 'xml-xerces', 'c')
        print 'Checking for %r...' % (xercesCRoot),
        
        if os.path.isdir(xercesCRoot): 
            print 'found'
        else:
            print 'not found'

            xercesCRoot = os.path.join('..', 'xml-xerces')
            print 'Checking for %r...' % (xercesCRoot),

            if os.path.isdir(xercesCRoot): 
                print 'found'
            else:
                print 'not found'
                xercesCRoot = None
        
    if xercesCRoot:
        include_dirs.append(getXercesIncludePath(xercesCRoot))
        xercesCLibPath = getXercesLibraryPath(xercesCRoot)
        library_dirs.append(xercesCLibPath)
        
        if sys.platform.startswith('win32'):
            data_files.append(os.path.join(xercesCLibPath, 'xerces-c_2_5_0.dll'))
            
    else:
        print 'Assuming Xerces include/library paths available from environment'
        
def getXalanIncludePath(xalanCRoot):
    # correct path in source distribution
    xalanCInclude = os.path.join(xalanCRoot, 'include')
    print 'Checking for Xalan include path as %r...' % xalanCInclude,
    
    if os.path.isdir(xalanCInclude):
        print 'found'
    else:
        print 'not found'

        # correct binary distribution
        xalanCInclude = os.path.join(xalanCRoot, 'src')
        print 'Checking for Xalan include path as %r...' % xalanCInclude,
        
        if os.path.isdir(xalanCInclude):
            print 'found'
        else:
            print 'not found'
            print 'Fatal error: Xalan include directory could not be found.'
            sys.exit(1)
    return xalanCInclude
        
if sys.platform.startswith('win32'): 
    def getXalanLibraryPath(xalanCRoot):
        if sys.version_info >= (2,4):
            # by default Python 2.4 is compiled with Visual Studio 7
            xalanCLibraryPath = os.path.join(xalanCRoot, 'Build\Win32\VC7\Release')
        else:
            xalanCLibraryPath = os.path.join(xalanCRoot, 'Build\Win32\VC6\Release')
        print 'Checking for Xalan library path as %r...' % xalanCLibraryPath,
        
        if os.path.isdir(xalanCLibraryPath):
            print 'found'
        else:
            print 'not found'
    
            print 'Fatal error:  Xalan library directory could not be found.'
            sys.exit(1)
        return xalanCLibraryPath
else:
    def getXalanLibraryPath(xalanCRoot):
        xalanCLibraryPath = os.path.join(xalanCRoot, 'lib')
        print 'Checking for Xalan library path as %r...' % xalanCLibraryPath,
        
        if os.path.isdir(xalanCLibraryPath):
            print 'found'
        else:
            print 'not found'
    
            print 'Fatal error: Xalan include library could not be found.'
            sys.exit(1)
        return xalanCLibraryPath

def setXalanVariables(include_dirs, library_dirs, defines, libraries, data_files):
    if sys.platform.startswith('win32'):
        libraries.append('Xalan-C_1')
    else:
        libraries.append('xalan-c')

    print 'Checking for "XALANCROOT" environment variable...',
    if os.environ.has_key('XALANCROOT'): 
        xalanCRoot = os.environ['XALANCROOT']
        print 'found'
    else:
        print 'not found'
        xalanCRoot = os.path.join('..', 'xml-xalan', 'c')
        print 'Checking for %r...' % (xalanCRoot),
        
        if os.path.isdir(xalanCRoot): 
            print 'found'
        else:
            print 'not found'
            xalanCRoot = None
    
    if xalanCRoot:
        include_dirs.append(getXalanIncludePath(xalanCRoot))
        xalanCLibPath = getXalanLibraryPath(xalanCRoot)
        library_dirs.append(xalanCLibPath)
        
        if sys.platform.startswith('win32'):
            data_files.append(os.path.join(xalanCLibPath, 'Xalan-C_1_8.dll'))
            data_files.append(os.path.join(xalanCLibPath, 'XalanMessages_1_8.dll'))

    else:
        print 'Assuming Xalan include/library paths available from environment'
        
defines = [] 
include_dirs = [] 
library_dirs = []
libraries = []
data_files = []

setXercesVariables(include_dirs, library_dirs, defines, libraries, data_files)
setXalanVariables(include_dirs, library_dirs, defines, libraries, data_files)
setPlatformDefines(defines)

xercesVersion = '2_5'
xalanVersion = '1_8'
        
# XXX This code works around a Distutils bug. It is probably quite fragile.
# You can comment out this entire block safely
if sys.platform.startswith('win32'):
    defines.append(('XERCES_VERSION', r'\"%s\"' % xercesVersion))
    defines.append(('XALAN_VERSION', r'\"%s\"' % xalanVersion))
else:
    defines.append(('XERCES_VERSION', r'"%s"' % xercesVersion))
    defines.append(('XALAN_VERSION', r'"%s"' % xalanVersion))

extra_compile_args = [] 

from distutils.command.install_data import install_data
class pyana_install_data(install_data):
    """Sets install_dir to be install directory of extension
    modules, instead of the root Python directory"""
    
    def finalize_options(self):
        if self.install_dir is None:
            installobj = self.distribution.get_command_obj('install')
            self.install_dir = installobj.install_platlib
        install_data.finalize_options(self)
    
setup(  name = "Pyana", 
        version = "0.9.2", 
        description = "Python bindings for the Xalan XSLT processor", 
        author = "Brian Quinlan", 
        author_email = "brian@sweetapp.com", 
        url = "http://pyana.sourceforge.net", 
        ext_package = "Pyana",
        cmdclass = {'install_data': pyana_install_data},
        scripts = ["Scripts/playpyana.py"],
        ext_modules = [Extension("_Pyana", ["Src/Boolean.cpp",
                            "Src/DocStrings.cpp",
                            "Src/ElemTemplateElement2PyObject.cpp",
                            "Src/ExceptionLiason.cpp",
                            "Src/GenerateEvent2PyObject.cpp",
                            "Src/LifeTimeManager.cpp",
                            "Src/Pyana.cpp",
                            "Src/PyanaTransformer.cpp",
                            "Src/PyanaTransformer2PyObject.cpp",
                            "Src/PyAutoReleasePool.cpp",
                            "Src/PyEntityResolver.cpp",
                            "Src/PyErrorHandler.cpp",
                            "Src/PyExtensionFunction.cpp", 
                            "Src/PyObjectInputSource.cpp", 
                            "Src/PyObjectInputStream.cpp", 
                            "Src/PyObjectOutputStream.cpp",
                            "Src/PyProblemListener.cpp",
                            "Src/PyReaderInputSource.cpp",
                            "Src/PyTraceListener.cpp",
                            "Src/RefCounted.cpp",
                            "Src/SelectionEvent2PyObject.cpp",
                            "Src/StringUtils.cpp",
                            "Src/TracerEvent2PyObject.cpp",
                            "Src/URI.cpp",
                            "Src/XalanCompiledStylesheet2PyObject.cpp",
                            "Src/XalanDocument2PyObject.cpp", 
                            "Src/XalanElement2PyObject.cpp", 
                            "Src/XalanNode2PyObject.cpp", 
                            "Src/XalanNode2PyObjectFactory.cpp", 
                            "Src/XalanNode2PyObjectOwnedFactory.cpp", 
                            "Src/XalanNode2PyObjectProxyFactory.cpp",
                            "Src/XalanNodeList2PyObject.cpp",
                            "Src/XalanParsedSource2PyObject.cpp",
                            "Src/XercesLiasonOwnedFactory.cpp",
                            "Src/XNodeSet2PyObject.cpp"],   
                        define_macros = defines, 
                        extra_compile_args = extra_compile_args, 
                        library_dirs = library_dirs, 
                        libraries = libraries, 
                        include_dirs = include_dirs)], 
        data_files = [('Pyana', data_files)], 
        py_modules =["Pyana.__init__"])
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.