File: setup.py

package info (click to toggle)
soya 0.12-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,580 kB
  • ctags: 20,171
  • sloc: cpp: 45,252; python: 7,241; ansic: 5,226; perl: 273; makefile: 227; sh: 65
file content (260 lines) | stat: -rw-r--r-- 8,395 bytes parent folder | download
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
# -*- indent-tabs-mode: t -*-

#! /usr/bin/env python

# Soya 3D
# Copyright (C) 2001-2002 Jean-Baptiste LAMY -- jiba@tuxfamily
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


# Modify the following if needed :
USE_ODE = 1     # use ODE
#USE_ODE = 0

USE_OPENAL = 1     # use OpenAL
#USE_OPENAL = 0

	

INCDIR = [
	"ode-0.5/include",
	"/usr/include",
	"/usr/local/include",
	"/usr/X11R6/include",
	"/usr/include/freetype2",
	"/usr/local/include/freetype2",
	"/usr/include/cal3d",
	"/usr/local/include/cal3d",
	"/sw/include", # For Mac OS X "fink"
    "/opt/local/include", # For Mac OS X "darwin port"
	]
LIBDIR = [
	"ode-0.5/lib",
	"/usr/lib",
	"/usr/local/lib",
	"/opt/local/lib", # For Mac OS X "darwin port"
	"/usr/X11R6/lib",
	"/sw/lib/", # For Mac OS X
	]


import os, os.path, sys, glob, distutils.core, distutils.sysconfig
from distutils.core import setup, Extension

HERE = os.path.dirname(sys.argv[0])
ODE_DIR = os.path.join(HERE, "ode-0.5")

BUILDING = ("build" in sys.argv[1:]) and not ("--help" in sys.argv[1:])
SDISTING = ("sdist" in sys.argv[1:]) and not ("--help" in sys.argv[1:])


try:
	from Pyrex.Distutils import build_ext
	HAVE_PYREX = 1
except:
	HAVE_PYREX = 0

endian = sys.byteorder
if endian == "big":
	DEFINES = [("SOYA_BIG_ENDIAN", endian)]
else:
	DEFINES = []

#from config import *

if sys.platform[:3] == "win":
	#LIBS = ["m", "glew32", "SDL", "SDL_mixer", "freetype", "cal3d", "stdc++"]
	LIBS = ["m", "glew32", "SDL", "freetype", "cal3d", "stdc++"]
else:
	#LIBS = ["m", "GLEW", "GL", "GLU", "SDL", "SDL_mixer", "freetype", "cal3d", "stdc++"]
	LIBS = ["m", "GLEW", "SDL", "freetype", "cal3d", "stdc++"]

SOYA_PYREX_SOURCES  = ["_soya.pyx", "matrix.c", "chunk.c" ]
SOYA_C_SOURCES      = ["_soya.c"  , "matrix.c", "chunk.c" ]


# Generate config.pxd and config.pyx
if BUILDING:
	CONFIG_PXD_FILE = open(os.path.join(HERE,"config.pxd"), "w")
	CONFIG_PXD_FILE.write("""# Machine-generated file, DO NOT EDIT!

""")
	CONFIG_PYX_FILE = open(os.path.join(HERE,"config.pyx"), "w")
	CONFIG_PYX_FILE.write("""# Machine-generated file, DO NOT EDIT!

""")
	if USE_OPENAL:
		print "Sound support (with OpenAL) enabled..."
		LIBS.append("openal")
		CONFIG_PXD_FILE.write("""include "sound/al.pxd"\n""")
		CONFIG_PYX_FILE.write("""include "sound/sound.pyx"\n""")
	else:
		print "Sound support (with OpenAL) disabled..."
		CONFIG_PYX_FILE.write("""include "sound/nosound.pyx"\n""")



# Taken from Twisted ; thanks to Christopher Armstrong :
#   make sure data files are installed in twisted package
#   this is evil.
import distutils.command.install_data
class install_data_twisted(distutils.command.install_data.install_data):
	def finalize_options(self):
		self.set_undefined_options('install', ('install_lib', 'install_dir'))
		distutils.command.install_data.install_data.finalize_options(self)


def do(command):
	print command
	r = os.system(command)
	if r:
		print "Failed !"
		sys.exit(1)
		
		
if USE_ODE:
	if BUILDING:
		if "--dont-build-ode" in sys.argv: sys.argv.remove("--dont-build-ode")
		elif os.path.exists(os.path.join(ODE_DIR, "lib", "libode.a")):
			# XXX Works only for Linux / Unix
			print "ODE and OPCODE have already been compiled; if you want to recompile them do:  cd %s ; make clean" % ODE_DIR
		else:
			print "Building ODE and OPCODE from %s" % ODE_DIR
			do("cd %s ; make clean" % ODE_DIR)
			do("cd %s ; make configure" % ODE_DIR)
			do("cd %s ; make" % ODE_DIR)
			print "ODE and OPCODE built successfully !"
			
	elif SDISTING:
		# Clean ODE, to remove configuration files and binaries
		do("cd %s ; make clean" % ODE_DIR)
	
	
if HAVE_PYREX:
	# make pyrex recompile the soya module if any of the .pyx files have changed
	# should probably recurse directories
	# much nicer than having to use --force
	soya_pyx_mtime=os.path.getmtime('_soya.pyx')
	for f in glob.glob('*.pyx'):
		if os.path.getmtime(f)>soya_pyx_mtime:
			os.utime('_soya.pyx',None)
			break
	
	KARGS = {
		"ext_modules" : [
		Extension("soya._soya", SOYA_PYREX_SOURCES,
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							),
		Extension("soya.opengl",   ["opengl.pyx"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							),
		Extension("soya.sdlconst", ["sdlconst.pyx"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							),
		],
		"cmdclass" : {
				'build_ext'   : build_ext,            # Pyrex magic stuff
				'install_data': install_data_twisted, # Put data with the lib
				},
		}

	if USE_ODE:
			KARGS["ext_modules"].append(
					Extension("soya._ode", ["_ode.pyx", "matrix.c"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS + ["ode","stdc++"], define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
			))
	
else:
	print
	print "PYREX NOT FOUND"
	print "Compiling the c file WITHOUT reading any .pyx files"
	print "This is OK as long as you don't modify Soya sources."
	print
	
 
	KARGS = {
		"ext_modules" : [
		Extension("soya._soya", SOYA_C_SOURCES,
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							),
		Extension("soya.opengl",   ["opengl.c"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							),
		Extension("soya.sdlconst", ["sdlconst.c"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS, define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
							)
		],
		"cmdclass" : {
				'install_data': install_data_twisted, # Put data with the lib
				},
		}

	if USE_ODE:
			KARGS["ext_modules"].append(
					Extension("soya._ode", ["_ode.c", "matrix.c"],
							include_dirs=INCDIR, library_dirs=LIBDIR,
							libraries=LIBS + ["ode","stdc++"], define_macros=DEFINES,
							extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
			))

if BUILDING:
	CONFIG_PXD_FILE.close()
	CONFIG_PYX_FILE.close()

setup(
	name         = "Soya",
	version      = "0.12",
	license      = "GPL",
	description  = "A practical high-level object-oriented 3D engine for Python.",
	long_description  = """A practical high-level object-oriented 3D engine for Python.
Soya is designed with game in mind. It includes heightmaps, particles systems, animation support,...""",
	keywords     = "3D engine openGL python",
	author       = "Jiba (LAMY Jean-Baptiste)",
	author_email = "jiba@tuxfamily.org",
	url          = "http://home.gna.org/oomadness/en/soya/index.html",
	classifiers  = [
  "Topic :: Games/Entertainment",
	"Topic :: Multimedia :: Graphics :: 3D Rendering",
	"Topic :: Software Development :: Libraries :: Python Modules",
	"Programming Language :: Python",
	"Intended Audience :: Developers",
	"Development Status :: 5 - Production/Stable",
	"License :: OSI Approved :: GNU General Public License (GPL)",
	],
	
	scripts      = ["soya_editor"],
	package_dir  = {"soya" : ""},
	packages     = ["soya", "soya.editor", "soya.pudding", "soya.pudding.ext", "soya.pudding.styles"],
	
	data_files   = [(os.path.join("soya", "data"),
									 [os.path.join("data", file) for file in os.listdir("data") if (file != "CVS") and (file != ".arch-ids") and (file != ".svn")]
									 )],
	**KARGS)