| 34 | | version = 'Trunk' |
| 35 | | modules = { |
| 36 | | '_core' : ['GLEW', 'GL', 'ode', 'glib-2.0'], |
| 37 | | '_datatypes' : ['GLEW', 'GL', 'ode', 'glib-2.0', 'openal'], |
| 38 | | '_internals' : ['glib-2.0', 'gthread-2.0'], |
| 39 | | 'actions' : ['ode'], |
| 40 | | 'atoms' : [], |
| 41 | | 'audio' : ['openal'], |
| 42 | | 'bodies' : ['GLEW','GL','ode'], |
| 43 | | 'colors' : ['GL'], |
| 44 | | 'controllers' : [], |
| 45 | | 'fields' : ['GL','ode'], |
| 46 | | 'joints' : ['GL','ode'], |
| 47 | | 'masses' : [ 'ode'], |
| 48 | | 'materials' : ['GL','GLEW'], |
| 49 | | 'models' : ['GLEW','GL','GLU','ode'], |
| 50 | | 'textures' : ['GLEW','GL', 'theora', 'ogg', 'cairo'], |
| 51 | | 'scenes' : ['GLEW', 'GL', 'ode'], |
| 52 | | 'shapes' : ['ode'], |
| 53 | | 'transports' : ['ogg'], |
| 54 | | 'widgets' : ['GLEW','GL','GLU'], |
| 55 | | } |
| 56 | | |
| 57 | | |
| 58 | | extensions =[] |
| 59 | | pyrex_sources=[] |
| 60 | | scripts =[] |
| 61 | | include_path =['include/'] |
| 62 | | for m in modules: |
| 63 | | pyrex_sources.append('src/%s/soy.%s.pyx'%(m,m)) |
| 64 | | |
| 65 | | |
| 66 | | ############################################################################ |
| 67 | | # Platform-dependent submodules |
| 68 | | |
| 69 | | # MS Windows |
| 70 | | if sys.platform == 'win32' : |
| 71 | | translate = { |
| 72 | | 'GLEW' : 'glew32', |
| 73 | | 'GL' : 'opengl32', |
| 74 | | 'ode' : 'ode', |
| 75 | | 'glib-2.0' : 'glib-2.0', |
| 76 | | 'gthread-2.0' : 'gthread-2.0', |
| 77 | | 'ogg' : 'ogg', |
| 78 | | 'GLU' : 'glu32', |
| 79 | | 'theora' : 'theora', |
| 80 | | 'cairo' : 'cairo', |
| 81 | | 'gdi32' : 'gdi32', |
| 82 | | 'openal' : 'openal', |
| 83 | | } |
| 84 | | modules['_core'].append('gdi32') |
| 85 | | for m in modules: |
| 86 | | extensions.append(Extension(name=m, |
| 87 | | sources=['src/%s/soy.%s.c'%(m,m)], |
| 88 | | libraries=[translate[i] for i in modules[m]])) |
| 89 | | scripts.append('win32_postinstall.py') |
| 90 | | |
| 91 | | # Apple OSX |
| 92 | | elif sys.platform == 'darwin' : |
| 93 | | frameworks = ['-framework', 'Carbon', |
| 94 | | '-framework', 'OpenGL', |
| 95 | | ] |
| 96 | | for m in modules: |
| 97 | | extensions.append(Extension(name=m, |
| 98 | | sources=['src/%s/soy.%s.c'%(m,m)], |
| 99 | | libraries=modules[m], |
| 100 | | extra_compile_args = frameworks, |
| 101 | | extra_link_args = frameworks)) |
| 102 | | |
| 103 | | # GNU/Linux, BSD, etc |
| 104 | | else : |
| 105 | | include_dirs = ['-I', '/usr/include/glib-2.0', |
| 106 | | '-I', '/usr/lib/glib-2.0/include', |
| 107 | | '-I', '/usr/include/cairo', |
| 108 | | '-I', '/usr/local/include', |
| 109 | | ] |
| 110 | | modules['_core'].append('X11') |
| 111 | | modules['_core'].append('Xxf86vm') |
| 112 | | for m in modules: |
| 113 | | extensions.append(Extension(name=m, |
| 114 | | sources=['src/%s/soy.%s.c'%(m,m)], |
| 115 | | extra_compile_args = include_dirs, |
| 116 | | libraries=modules[m])) |
| 117 | | |
| 118 | | # |
| 119 | | ############################################################################ |
| 120 | | |
| 121 | | |
| 122 | | # process Pyrex sources to C |
| 123 | | |
| 124 | | options = Main.CompilationOptions(defaults=Main.default_options, |
| 125 | | include_path=include_path) |
| 126 | | |
| 127 | | newestpxd = 0 |
| 128 | | for dir in include_path: |
| 129 | | for pxdsource in os.listdir(dir): |
| 130 | | pxdsource_path = (os.path.join(dir, pxdsource)) |
| 131 | | |
| 132 | | if os.path.isfile(pxdsource_path) and \ |
| 133 | | os.path.splitext(pxdsource_path)[1] == '.pxd' and \ |
| 134 | | os.stat(pxdsource_path)[ST_MTIME] > newestpxd : |
| 135 | | newestpxd = os.stat(pxdsource_path)[ST_MTIME] |
| 136 | | |
| 137 | | error = False |
| 138 | | for pyxsource in pyrex_sources: |
| 139 | | csource = os.path.splitext(pyxsource)[0] + '.c' |
| 140 | | if os.path.isfile(csource) : |
| 141 | | ctime = os.stat(csource)[ST_MTIME] |
| 142 | | else: |
| 143 | | ctime = 0 |
| 144 | | |
| 145 | | pyxsourcedir = os.path.split(pyxsource)[0] |
| 146 | | pxisources = [] |
| 147 | | for pfile in os.listdir(pyxsourcedir) : |
| 148 | | if (os.path.splitext(pfile)[1] == '.pxi' or |
| 149 | | os.path.splitext(pfile)[1] == '.pym' ) : |
| 150 | | pxisources.append('%s/%s'%(pyxsourcedir,pfile)) |
| 151 | | |
| 152 | | newestpxi = 0 |
| 153 | | for pxisource in pxisources : |
| 154 | | pxitime = os.stat(pxisource)[ST_MTIME] |
| 155 | | if pxitime>newestpxi : |
| 156 | | newestpxi = pxitime |
| 157 | | |
| 158 | | pyxtime = os.stat(pyxsource)[ST_MTIME] |
| 159 | | if newestpxd > ctime or newestpxi > ctime or pyxtime > ctime : |
| 160 | | extname = os.path.splitext(pyxsource)[0].split('/')[-1][4:] |
| 161 | | print "processing '%s' extension" % extname |
| 162 | | result = Main.compile(pyxsource, options) |
| 163 | | if Main.Version.version < '0.9.8.5' : |
| 164 | | os.remove(os.path.splitext(pyxsource)[0] + '.dep') |
| 165 | | if result.num_errors: |
| 166 | | error = True |
| 167 | | |
| 168 | | if error: |
| 169 | | raise Exception("Error compiling Pyrex sources: Aborting compilation.") |
| 170 | | |
| 171 | | |
| 172 | | setup( |
| 173 | | name = 'PySoy', |
| 174 | | version = version, |
| 175 | | description = '3D Game Engine for Python', |
| 176 | | long_description = ''' ''', |
| 177 | | author = 'PySoy Group', |
| 178 | | author_email = 'pysoy-dev@pysoy.org', |
| 179 | | maintainer = 'Arc Riley', |
| 180 | | maintainer_email = 'arc@pysoy.org', |
| 181 | | url = 'http://pysoy.org/', |
| 182 | | download_url = 'http://svn.pysoy.org/trunk/pysoy', |
| 183 | | packages = ['soy'], |
| 184 | | package_dir = {'soy' : 'scripts'}, |
| 185 | | ext_package = 'soy', |
| 186 | | ext_modules = extensions, |
| 187 | | classifiers = [ |
| 188 | | 'Development Status :: 4 - Beta', |
| 189 | | 'Intended Audience :: Developers', |
| 190 | | 'Natural Language :: English', |
| 191 | | 'Topic :: Education', |
| 192 | | 'Topic :: Games/Entertainment', |
| 193 | | 'Topic :: Multimedia :: Graphics', |
| 194 | | 'Topic :: Scientific/Engineering :: Artificial Intelligence', |
| 195 | | 'Topic :: Scientific/Engineering :: Human Machine Interfaces', |
| 196 | | 'Topic :: Scientific/Engineering :: Visualization', |
| 197 | | 'License :: OSI Approved :: GNU Affero General Public License (AGPL)' ], |
| 198 | | license = 'GNU Affero General Public License version 3 (AGPLv3)', |
| 199 | | # This is so we can have code written in C thrown in with our Pyrex code. |
| 200 | | # (This is used in particular to access the Windows API without binding |
| 201 | | # a huge swath of it to Pyrex, and do some preprocessor trickery.) |
| 202 | | include_dirs = [os.path.abspath(p) for p in include_path], |
| 203 | | scripts = scripts, |
| 204 | | ) |
| | 33 | def render(self, template, context) : |
| | 34 | tmpl = self.loader.load(template) |
| | 35 | return tmpl.generate(**context).render(method='html') |