3
# This is the distutils setup script for pygame.
4
# Full instructions are in "docs/fullinstall.txt"
6
# To configure, compile, install, just run this script.
8
DESCRIPTION = """Pygame is a Python wrapper module for the
9
SDL multimedia library. It contains python functions and classes
10
that will allow you to use SDL's support for playing cdroms,
11
audio and video output, and keyboard, mouse and joystick input."""
17
"url": "http://www.pygame.org",
18
"author": "Pete Shinners",
19
"author_email": "pygame@seul.org",
20
"description": "Python Game Development",
21
"long_description": DESCRIPTION,
27
raise SystemExit, "Pygame requires distutils to build and install."
30
#get us to the correct directory
32
path = os.path.split(os.path.abspath(sys.argv[0]))[0]
38
import distutils.sysconfig
39
from distutils.core import setup, Extension
40
from distutils.extension import read_setup_file
41
from distutils.ccompiler import new_compiler
42
from distutils.command.install_data import install_data
46
headers = glob.glob(os.path.join('src', '*.h'))
49
#sanity check for any arguments
50
if len(sys.argv) == 1:
51
reply = raw_input('\nNo Arguments Given, Perform Default Install? [Y/n]')
52
if not reply or reply[0].lower() != 'n':
53
sys.argv.append('install')
56
#make sure there is a Setup file
57
if not os.path.isfile('Setup'):
58
print '\n\nWARNING, No "Setup" File Exists, Running "config.py"'
61
print '\nContinuing With "setup.py"'
65
#get compile info for all extensions
67
extensions = read_setup_file('Setup')
69
raise SystemExit, """Error with the "Setup" file,
70
perhaps make a clean copy from "Setup.in"."""
73
#extra files to install
74
data_path = os.path.join(distutils.sysconfig.get_python_lib(), 'pygame')
78
#add non .py files in lib directory
79
for f in glob.glob(os.path.join('lib', '*')):
80
if not f[-3:] =='.py' and os.path.isfile(f):
84
#try to find DLLs and copy them too (only on windows)
85
if sys.platform == 'win32':
86
tempcompiler = new_compiler()
89
ext = tempcompiler.shared_lib_extension
90
for d in e.library_dirs:
92
name = tempcompiler.shared_lib_format%(l, ext)
93
paths.append(os.path.join(d, name))
95
if os.path.isfile(p) and p not in data_files:
99
#we can detect the presence of python dependencies, remove any unfound
100
pythondeps = {'surfarray': ['Numeric']}
101
for e in extensions[:]:
102
modules = pythondeps.get(e.name, [])
105
for module in modules:
106
x = __import__(module)
109
print 'NOTE: Not compiling:', e.name, ' (module not found='+module+')'
113
#clean up the list of extensions
114
for e in extensions[:]:
115
if e.name[:8] == 'COPYLIB_':
116
extensions.remove(e) #don't compile the COPYLIBs, just clean them
118
e.name = 'pygame.' + e.name #prepend package name on modules
122
#data installer with improved intelligence over distutils
123
#data files are copied into the project directory instead
125
class smart_install_data(install_data):
127
#need to change self.install_dir to the library dir
129
install_cmd = self.get_finalized_command('install')
130
self.install_dir = getattr(install_cmd, 'install_lib')
131
return install_data.run(self)
139
#call distutils with all needed info
141
"cmdclass": {'install_data': smart_install_data},
142
"packages": ['pygame'],
143
"package_dir": {'pygame': 'lib'},
145
"ext_modules": extensions,
146
"data_files": [['pygame', data_files]],
148
PACKAGEDATA.update(METADATA)
149
apply(setup, [], PACKAGEDATA)