root/setup.py

Revision 1482:a8ea58863b59, 5.6 KB (checked in by Arc Riley <arcriley@…>, 4 months ago)

beginning move to pkgconfig - this needs a lot more cleanup

  • Property exe set to *
Line 
1#!/usr/bin/env python3.0
2''' PySoy's compile and install script '''
3__credits__ = '''Copyright (C) 2006,2007,2008,2009 PySoy Group
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU Affero General Public License as published
7    by the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program; if not, see http://www.gnu.org/licenses
17'''
18__author__  = 'PySoy Group'
19__date__    = 'Last change on '+ \
20              '$Date: 2009-01-26 15:26:56 -0500 (Mon, 26 Jan 2009) $'[7:-20]+ \
21              'by '+'$Author: ArcRiley $'[9:-2]
22__version__ = 'Trunk (r'+'$Rev: 1506 $'[6:-2]+')'
23
24import os
25import sys
26
27if sys.version_info[0] != 3 :
28  raise RuntimeError('Python 3.0 is required for this package.')
29
30import platform
31from stat import *
32from subprocess import getoutput
33from mill.distutils.core import setup
34from distutils import ccompiler
35from distutils.extension import Extension
36
37version = 'Trunk'
38
39extensions    = []
40scripts       = []
41packages      = ['bullet', 'gl', 'glib-2.0', 'gdk-2.0', 'cairo', 'pango', 
42                 'liboil-0.3', 'ogg', 'theora']
43
44include_path  = ['include/']
45include_dirs  = []
46libraries     = []
47
48#
49############################################################################
50# compile libsoy
51print("compiling libsoy")
52
53# get build directories
54temp_dir = 'build/temp.%s-%s-sys' % (platform.system().lower(), 
55                                     platform.machine())
56linked_dir = 'build/lib.%s-%s-sys' %  (platform.system().lower(),
57                                       platform.machine())
58
59# Create build directories (if needed)
60if (not os.path.isdir(temp_dir)):
61  os.makedirs(temp_dir)
62if (not os.path.isdir(linked_dir)):
63  os.makedirs(linked_dir)
64
65# build vsources list with every lib/*.vala file
66vsources = []
67
68for vfile in os.listdir('lib') :
69  if os.path.splitext(vfile)[1] == '.vala' :
70    vsources.append('%s/%s'%('lib', vfile))
71
72# compile vala to c
73exe = 'valac --vapidir=vapi --pkg=gl --pkg=gdk-2.0 -C '\
74      '-H %s/include/soy.h ' % (temp_dir) +\
75      '-d %s %s' % (temp_dir, ' '.join(vsources))
76
77print(exe)
78os.system(exe)
79
80# build csources and headers list with every temp_dir/*.c/*.h file
81def _addpath(base,file) :
82  return '%s/%s' % (base,file)
83templib_dir = '%s/lib'%temp_dir
84tempinc_dir = '%s/include'%temp_dir
85csources = [_addpath(templib_dir, file) for file in os.listdir(templib_dir)]
86headers  = [_addpath(tempinc_dir, file) for file in os.listdir(tempinc_dir)]
87
88# compile and link libsoy as a shared library
89if   sys.platform == 'win32'  :
90  compiler = ccompiler.new_compiler(compiler="mingw32")
91  objs = compiler.compile(csources, output_dir=temp_dir, 
92                           extra_preargs=['-fpic'],
93                          depends=headers)
94  compiler.link_shared_lib(objs, 'soy', output_dir=linked_dir, 
95                           libraries=[translate[i] for i in libraries])
96  libsoy = ['%s/%s' % (linked_dir, 
97                       compiler.library_filename('soy', lib_type='shared'))]
98else :
99  compiler = ccompiler.new_compiler(compiler="unix")
100  objs = compiler.compile(csources, output_dir=temp_dir, 
101                          extra_preargs=['-fpic'] + \
102                          getoutput("pkg-config --cflags %s" % (
103                           ' '.join(packages))).split(),
104                          depends=headers)
105  compiler.link_shared_lib(objs, 'soy', output_dir=linked_dir, 
106                           extra_preargs=getoutput("pkg-config --libs %s" % (
107                           ' '.join(packages))).split())
108  libsoy = ['%s/%s' % (linked_dir, 
109                       compiler.library_filename('soy', lib_type='shared'))]
110
111#
112############################################################################
113# build/install PySoy
114
115setup(
116  name             = 'PySoy',
117  version          = version,
118  description      = '3D Game Engine for Python',
119  long_description = ''' ''',
120  author           = 'PySoy Group',
121  author_email     = 'pysoy-dev@pysoy.org',
122  maintainer       = 'Arc Riley',
123  maintainer_email = 'arc@pysoy.org',
124  url              = 'http://pysoy.org/',
125  download_url     = 'http://hg.pysoy.org/pysoy',
126  packages         = ['soy'],
127  package_dir      = {'soy' : 'scripts'},
128  ext_package      = 'soy',
129  ext_modules      = [
130    Extension(
131      name         = 'scenes',
132      sources      = [ #'src/scenes/__init__.vala',
133      ],
134      include_dirs = include_dirs,
135      libraries    = libraries,
136      extra_compile_args = ['-g'],
137    ),
138  ],
139  data_files       = [('lib', libsoy), # install libsoy to sys.exec_prefix/lib
140                      ('include', headers)], # install headers as well
141  classifiers      = [
142    'Development Status :: 4 - Beta',
143    'Intended Audience :: Developers',
144    'License :: OSI Approved :: GNU Affero General Public License v3',
145    'Natural Language :: English',
146    'Topic :: Education',
147    'Topic :: Games/Entertainment',
148    'Topic :: Multimedia :: Graphics',
149    'Topic :: Scientific/Engineering :: Artificial Intelligence',
150    'Topic :: Scientific/Engineering :: Human Machine Interfaces',
151    'Topic :: Scientific/Engineering :: Visualization',
152  ],
153  license          = 'GNU Affero General Public License version 3 (AGPLv3)',
154  include_dirs     = [os.path.abspath(p) for p in include_path],
155  scripts          = scripts,
156)
Note: See TracBrowser for help on using the browser.