#!/usr/bin/env python## This is the distutils setup script for pygame.# Full instructions are in "docs/fullinstall.txt"## To configure, compile, install, just run this script.DESCRIPTION="""Pygame is a Python wrapper module for theSDL multimedia library. It contains python functions and classesthat will allow you to use SDL's support for playing cdroms,audio and video output, and keyboard, mouse and joystick input."""METADATA={"name":"pygame","version":"1.4.1","license":"LGPL","url":"http://www.pygame.org","author":"Pete Shinners","author_email":"pygame@seul.org","description":"Python Game Development","long_description":DESCRIPTION,}try:importdistutilsexceptImportError:raiseSystemExit,"Pygame requires distutils to build and install."#get us to the correct directoryimportos,syspath=os.path.split(os.path.abspath(sys.argv[0]))[0]os.chdir(path)importos.path,globimportdistutils.sysconfigfromdistutils.coreimportsetup,Extensionfromdistutils.extensionimportread_setup_filefromdistutils.ccompilerimportnew_compilerfromdistutils.command.install_dataimportinstall_data#headers to installheaders=glob.glob(os.path.join('src','*.h'))#sanity check for any argumentsiflen(sys.argv)==1:reply=raw_input('\nNo Arguments Given, Perform Default Install? [Y/n]')ifnotreplyorreply[0].lower()!='n':sys.argv.append('install')#make sure there is a Setup fileifnotos.path.isfile('Setup'):print'\n\nWARNING, No "Setup" File Exists, Running "config.py"'importconfigconfig.main()print'\nContinuing With "setup.py"'#get compile info for all extensionstry:extensions=read_setup_file('Setup')except:raiseSystemExit,"""Error with the "Setup" file,perhaps make a clean copy from "Setup.in"."""#extra files to installdata_path=os.path.join(distutils.sysconfig.get_python_lib(),'pygame')data_files=[]#add non .py files in lib directoryforfinglob.glob(os.path.join('lib','*')):ifnotf[-3:]=='.py'andos.path.isfile(f):data_files.append(f)#try to find DLLs and copy them too (only on windows)ifsys.platform=='win32':tempcompiler=new_compiler()foreinextensions:paths=[]ext=tempcompiler.shared_lib_extensionfordine.library_dirs:forline.libraries:name=tempcompiler.shared_lib_format%(l,ext)paths.append(os.path.join(d,name))forpinpaths:ifos.path.isfile(p)andpnotindata_files:data_files.append(p)#we can detect the presence of python dependencies, remove any unfoundpythondeps={'surfarray':['Numeric']}foreinextensions[:]:modules=pythondeps.get(e.name,[])ifmodules:try:formoduleinmodules:x=__import__(module)delxexceptImportError:print'NOTE: Not compiling:',e.name,' (module not found='+module+')'extensions.remove(e)#clean up the list of extensionsforeinextensions[:]:ife.name[:8]=='COPYLIB_':extensions.remove(e)#don't compile the COPYLIBs, just clean themelse:e.name='pygame.'+e.name#prepend package name on modules#data installer with improved intelligence over distutils#data files are copied into the project directory instead#of willy-nillyclasssmart_install_data(install_data):defrun(self):#need to change self.install_dir to the library dirinstall_cmd=self.get_finalized_command('install')self.install_dir=getattr(install_cmd,'install_lib')returninstall_data.run(self)#finally, #call distutils with all needed infoPACKAGEDATA={"cmdclass":{'install_data':smart_install_data},"packages":['pygame'],"package_dir":{'pygame':'lib'},"headers":headers,"ext_modules":extensions,"data_files":[['pygame',data_files]],}PACKAGEDATA.update(METADATA)apply(setup,[],PACKAGEDATA)