pygame is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againpygame / setup.py
- Branch
- pgreloaded
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | #!/usr/bin/env python
import os, sys, glob, time, re
import distutils.sysconfig
from distutils.core import setup
from distutils.command.install_data import install_data
import modules, cfg
from config import helpers, msys, config_modules
VERSION = "2.0.0-alpha5"
DEBUG = True
# Minimum requirements.
PYTHON_MINIMUM = (2, 4)
# Data installer with improved intelligence over distutils.
# Data files are copied into the project directory instead of willy-nilly
class SmartInstallData(install_data):
def run(self):
# Need to change self.install_dir to the actual library dir.
install_cmd = self.get_finalized_command ('install')
self.install_dir = getattr (install_cmd, 'install_lib')
return install_data.run (self)
def find_pkg_data (directory, excludedirs=[], excludefiles=[]):
pkgdata = []
nodirs = re.compile (r'(.svn)$')
nofilesrev = re.compile (r'((~.*)|(cyp\..*)|(yp\..*))')
for subd, directories, files in os.walk (directory):
directories[:] = [d for d in directories if nodirs.match (d) is None \
and d not in excludedirs]
files[:] = [f for f in files if nofilesrev.match(f[-1::-1]) is None \
and f not in excludefiles]
subd = subd.replace (directory, "", 1)
subd = subd.lstrip (os.path.sep)
for f in files:
pkgdata.append (os.path.join (subd, f))
return pkgdata
def get_compiler (args):
coffset = 0
compiler = ''
if '-c' in args:
coffset = args.index ('-c')
if coffset < len (args) - 1:
compiler = args[coffset+1]
else:
for arg in args:
if '--compiler=' in arg:
compiler = arg.split ('=')[1]
return compiler
def run_checks ():
# Python version check.
if helpers.getversion () < PYTHON_MINIMUM: # major, minor check
raise Exception ("You should have at least Python >= %d.%d.x "
"installed." % PYTHON_MINIMUM)
buildsystem = None
builddefines = []
defcompiler = ''
if sys.platform == "win32":
if msys.is_msys ():
buildsystem = "msys"
builddefines.append (("IS_MSYS", None))
defcompiler = "mingw32"
else:
buildsystem = "win"
builddefines.append (("IS_WIN32", None))
builddefines.append (("WIN32", None))
defcompiler = "msvc"
elif sys.platform == "darwin":
buildsystem = "darwin"
builddefines.append (("IS_DARWIN", None))
defcompiler = "unix"
else:
buildsystem = "unix"
defcompiler = "unix"
builddefines.append (("IS_UNIX", None))
if cfg.build['SDL']:
sdlversion = config_modules.sdl_get_version (buildsystem)
compiler = get_compiler (sys.argv) or defcompiler
print ("\nThe following information will be used to build Pygame:")
print ("\t System: %s" % buildsystem)
print ("\t Python: %d.%d.%d" % helpers.getversion ())
print ("\t Compiler: %s" % compiler)
if cfg.build['SDL']:
print ("\t SDL: %s" % sdlversion)
return buildsystem, builddefines, compiler
if __name__ == "__main__":
buildsystem = None
buildcflags = None
try:
buildsystem, builddefines, compiler = run_checks ()
except:
print (helpers.geterror ())
print (helpers.gettraceback ())
sys.exit (1)
os.environ["CFLAGS"] = ""
if "bdist_msi" in sys.argv:
# hack the version name to a format msi doesn't have trouble with
VERSION = VERSION.replace("-alpha", "a")
VERSION = VERSION.replace("-rc", "r")
if DEBUG and buildsystem in ("msys", "unix", "darwin") and \
compiler in ("unix", "cygwin", "mingw32", "mingw32-console"):
os.environ["CFLAGS"] += " -W -Wall -Wimplicit-int " + \
"-Wimplicit-function-declaration " + \
"-Wimplicit -Wreturn-type -Wunused " + \
"-Wswitch -Wcomment -Wtrigraphs -Wformat " + \
"-Wchar-subscripts -Wuninitialized -Wparentheses " +\
"-Wpointer-arith -Wcast-qual -Winline " + \
"-Wcast-align -Wconversion -Wstrict-prototypes " + \
"-Wmissing-prototypes -Wmissing-declarations " + \
"-Wnested-externs -Wshadow -Wredundant-decls -g -pg"
# When building in Mac OS, we must make sure that all
# modules are built as universal binaries.
# FIXME: Find a better place for this?
if buildsystem == "darwin":
os.environ["CFLAGS"] += " -arch i386 -arch ppc"
packages = [ "pygame2",
"pygame2.examples",
"pygame2.examples.freetype",
"pygame2.examples.sdl",
"pygame2.examples.sdlext",
"pygame2.examples.sdlgfx",
"pygame2.sprite",
"pygame2.threads",
"pygame2.test",
"pygame2.test.util",
"pygame2.dll",
]
package_dir = { "pygame2" : "lib",
"pygame2.examples" : "examples",
"pygame2.sprite" : os.path.join ("lib", "sprite"),
"pygame2.threads" : os.path.join ("lib", "threads"),
"pygame2.test" : "test",
"pygame2.test.util" : os.path.join ("test", "util"),
}
package_data = {
"pygame2.examples" : find_pkg_data ("examples"),
"pygame2.test" : find_pkg_data ("test"),
}
dllfiles = [ os.path.join ("pygame2", "dll"),
config_modules.get_install_libs (buildsystem, cfg) ]
ext_modules = modules.get_extensions (buildsystem, compiler)
modules.update_packages (ext_modules, packages, package_dir, package_data)
headerfiles = []
print ("The following modules will be built:")
for ext in ext_modules:
ext.define_macros.extend (builddefines)
headerfiles += ext.basemodule.installheaders
print ("\t%s" % ext.name)
# Allow the user to read what was printed
time.sleep (2)
# Create doc headers on demand.
docincpath = os.path.join ("src", "doc")
if not os.path.exists (docincpath):
os.mkdir (docincpath)
for ext in ext_modules:
modules.create_docheader (ext.basemodule, docincpath)
setupdata = {
"cmdclass" : { "install_data" : SmartInstallData },
"name" : "pygame2",
"version" : VERSION,
"description" : "Python Game Development Library",
"author" : "Pete Shinners, Rene Dudfield, Marcus von Appen, Lenard Lindstrom, Brian Fisher, others...",
"author_email" : "pygame@seul.org",
"license" : "LGPL",
"url" : "http://pygame.org",
"packages" : packages,
"package_dir" : package_dir,
"package_data" : package_data,
"headers" : headerfiles,
"ext_modules" : ext_modules,
"data_files" : [ dllfiles ],
}
setup (**setupdata)
|