forked from bitcraft/pyglet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
313 lines (268 loc) · 11.1 KB
/
setup.py
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/usr/bin/env python
"""
"""
__docformat__ = 'restructuredtext'
__version__ = '$Id$'
import os
import shutil
import sys
# Bump pyglet/__init__.py version as well.
VERSION = '1.2alpha1-lt'
long_description = """pyglet provides an object-oriented programming
interface for developing visually-rich games for Windows, Mac OS X and Linux."""
setup_info = dict(
# Metadata
name='pyglet',
version=VERSION,
author='Alex Holkner',
author_email='Alex.Holkner@gmail.com',
url='http://www.pyglet.org/',
download_url='http://pypi.python.org/pypi/pyglet',
description='Cross-platform windowing and multimedia library',
long_description=long_description,
license='BSD',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Games/Entertainment',
'Topic :: Software Development :: Libraries :: Python Modules',
],
# Package info
packages=[
'pyglet',
'pyglet.app',
'pyglet.canvas',
'pyglet.font',
'pyglet.gl',
'pyglet.graphics',
'pyglet.image',
'pyglet.image.codecs',
'pyglet.input',
'pyglet.libs',
'pyglet.libs.darwin',
'pyglet.libs.darwin.cocoapy',
'pyglet.libs.win32',
'pyglet.libs.x11',
'pyglet.media',
'pyglet.media.drivers',
'pyglet.media.drivers.directsound',
'pyglet.media.drivers.openal',
'pyglet.media.drivers.pulse',
'pyglet.text',
'pyglet.text.formats',
'pyglet.window',
'pyglet.window.cocoa',
'pyglet.window.win32',
'pyglet.window.xlib',
],
# Add _ prefix to the names of temporary build dirs
options={
'build': {'build_base': '_build'},
'sdist': {'dist_dir': '_dist'},
}
)
setuptools_info = dict(
zip_safe=True,
)
if 'bdist_egg' in sys.argv or 'develop' in sys.argv:
from setuptools import setup
_have_setuptools = True
# Don't walk SVN tree for default manifest
from setuptools.command import egg_info
from setuptools.command import sdist
egg_info.walk_revctrl = lambda: list()
sdist.walk_revctrl = lambda: list()
# Insert additional command-line arguments into install_lib when
# bdist_egg calls it, to compile byte-code with optimizations.
# This is a dirty hack.
from setuptools.command import bdist_egg
old_call_command = bdist_egg.bdist_egg.call_command
def call_command(self, *args, **kwargs):
if args[0] == 'install_lib':
kwargs['optimize'] = 2
kwargs['compile'] = False
cmd = old_call_command(self, *args, **kwargs)
return cmd
bdist_egg.bdist_egg.call_command = call_command
elif 'bdist_mpkg' in sys.argv:
from setuptools import setup
_have_setuptools = True
from bdist_mpkg_pyglet import plists, pkg, cmd_bdist_mpkg, tools
# Check for ctypes if installing into Python 2.4
def ctypes_requirement(pkgname, prefix):
prefix = os.path.join(prefix, 'ctypes')
title = '%s requires ctypes 1.0 or later to install with Python 2.4' \
% pkgname
kw = dict(
LabelKey='ctypes',
TitleKey=title,
MessageKey=title,
)
return plists.path_requirement(prefix, **kw)
# Subclass bdist_mpkg
class pyglet_bdist_mpkg(cmd_bdist_mpkg.bdist_mpkg):
# Don't include platform or python version in mpkg name (aesthetics)
def finalize_package_data(self):
cmd_bdist_mpkg.bdist_mpkg.finalize_package_data(self)
self.metapackagename = '-'.join([self.get_name(),
self.get_version()]) + '.mpkg'
self.pseudoinstall_root = self.get_pseudoinstall_root()
self.packagesdir = os.path.join(
self.get_metapackage(),
self.component_directory
)
def get_metapackage_info(self):
info = dict(cmd_bdist_mpkg.bdist_mpkg.get_metapackage_info(self))
info.update(dict(
# Set background image alignment
IFPkgFlagBackgroundScaling='none',
IFPkgFlagBackgroundAlignment='topleft',
# Remove specific Python version requirement from metapackage,
# is per-package now.
IFRequirementDicts=list(),
))
return info
# Override how packages are made. purelib forces creation of a
# separate package for each required python version, all symlinked to
# the same Archive.bom.
def make_scheme_package(self, scheme):
assert scheme == 'purelib'
# Make AVbin package
pkgname = 'AVbin'
pkgfile = pkgname + '.pkg'
self.packages.append((pkgfile, self.get_scheme_status(scheme)))
pkgdir = os.path.join(self.packagesdir, pkgfile)
self.mkpath(pkgdir)
version = self.get_scheme_version(scheme)
info = dict(self.get_scheme_info(scheme))
description = 'AVbin audio and video support (recommended)'
files = list(tools.walk_files('build/avbin'))
common = 'build/avbin'
prefix = '/usr/local/lib'
pkg.make_package(self,
pkgname, version,
files, common, prefix,
pkgdir,
info, description)
# pyglet packages
files, common, prefix = self.get_scheme_root(scheme)
def add_package(python_dir, package_dir,
pyver, pkgname, description):
scheme_prefix = package_dir
pkgfile = pkgname + '.pkg'
self.packages.append((pkgfile, self.get_scheme_status(scheme)))
pkgdir = os.path.join(self.packagesdir, pkgfile)
self.mkpath(pkgdir)
version = self.get_scheme_version(scheme)
requirements = [
plists.python_requirement(self.get_name(),
prefix=python_dir,
version=pyver)]
if pyver == '2.4':
requirements.append(ctypes_requirement(self.get_name(),
prefix=scheme_prefix))
info = dict(self.get_scheme_info(scheme))
info.update(dict(
IFRequirementDicts=requirements,
))
pkg.make_package(self,
pkgname, version,
files, common, scheme_prefix,
pkgdir,
info,
description,
)
# Move the archive up to the metapackage and symlink to it
pkgfile = os.path.join(pkgdir, 'Contents/Archive.pax.gz')
shutil.move(pkgfile,
os.path.join(pkgdir, '../../Archive.pax.gz'))
os.symlink('../../../Archive.pax.gz', pkgfile)
pkgfile = os.path.join(pkgdir, 'Contents/Archive.bom')
shutil.move(pkgfile,
os.path.join(pkgdir, '../../Archive.bom'))
os.symlink('../../../Archive.bom', pkgfile)
self.scheme_hook(scheme, pkgname, version, files, common,
prefix, pkgdir)
add_package(
'/System/Library/Frameworks/Python.framework/Versions/2.5',
'/Library/Python/2.5/site-packages',
'2.5', 'pyglet-syspy2.5',
'pyglet for Python 2.5 in /System/Library')
add_package(
'/System/Library/Frameworks/Python.framework/Versions/2.6',
'/Library/Python/2.6/site-packages',
'2.6', 'pyglet-syspy2.6',
'pyglet for Python 2.6 in /System/Library')
add_package(
'/Library/Frameworks/Python.framework/Versions/2.4',
'/Library/Frameworks/Python.framework/Versions/2.4'
'/lib/python2.4/site-packages',
'2.4', 'pyglet-py2.4',
'pyglet for Python 2.4 in /Library')
add_package(
'/Library/Frameworks/Python.framework/Versions/2.5',
'/Library/Frameworks/Python.framework/Versions/2.5'
'/lib/python2.5/site-packages',
'2.5', 'pyglet-py2.5',
'pyglet for Python 2.5 in /Library')
add_package(
'/Library/Frameworks/Python.framework/Versions/2.6',
'/Library/Frameworks/Python.framework/Versions/2.6'
'/lib/python2.6/site-packages',
'2.6', 'pyglet-py2.6',
'pyglet for Python 2.6 in /Library')
add_package(
'/opt/local/',
'/opt/local/lib/python2.4/site-packages',
'2.4', 'pyglet-macports-py2.4',
'pyglet for MacPorts Python 2.4 in /opt/local')
add_package(
'/opt/local/',
'/opt/local/lib/python2.5/site-packages',
'2.5', 'pyglet-macports-py2.5',
'pyglet for MacPorts Python 2.5 in /opt/local')
add_package(
'/opt/local/',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.6'
'/lib/python2.6/site-packages',
'2.6', 'pyglet-macports-py2.6',
'pyglet for MacPorts Python 2.6 in /opt/local')
# Don't build to an absolute path, assume within site-packages (makes
# it easier to symlink the same archive for all packages)
def get_scheme_install_prefix(self, scheme):
return scheme
# Don't byte compile (waste of space, try to do it in postflight TODO).
def byte_compile(self):
pass
setuptools_info.update(dict(
cmdclass={'bdist_mpkg': pyglet_bdist_mpkg, }
))
else:
from distutils.core import setup
_have_setuptools = False
if _have_setuptools:
# Additional dict values for setuptools
setup_info.update(setuptools_info)
install_requires = list()
if sys.version_info < (2, 5, 0):
install_requires.append('ctypes')
setup_info.update(dict(
install_requires=install_requires,
))
# if sys.version_info >= (3,):
# # Automatically run 2to3 when using Python 3
# if _have_setuptools:
# setup_info["use_2to3"] = True
# else:
# from distutils.command.build_py import build_py_2to3
#
# setup_info["cmdclass"] = {"build_py": build_py_2to3}
setup(**setup_info)