From: Diane Trout Date: Thu, 11 May 2006 03:20:43 +0000 (+0000) Subject: try to make setup.py multiplatform X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=16fb9977e236e595ec3cb4336488ebb6eb5bd20a try to make setup.py multiplatform --- diff --git a/setup.py b/setup.py index 5f0d12a..6055872 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ from setuptools import setup, Extension import distutils.command.build_ext from distutils.dep_util import newer -import py2app import os +import sys def replace_suffix(path, new_suffix): return os.path.splitext(path)[0]+new_suffix @@ -11,6 +11,18 @@ def replace_suffix(path, new_suffix): class build_ext(distutils.command.build_ext.build_ext): description="also compile qt moc files" + def __init__(self, *args, **kwargs): + if sys.platform == 'linux2': + self.moc_binary = 'moc' + self.rcc_binary = 'rcc' + + if os.path.exists('/usr/bin/moc-qt4'): + self.moc_binary = '/usr/bin/moc-qt4' + if os.path.exists('/usr/bin/rcc-qt4'): + self.rcc_binary = '/usr/bin/rcc-qt4' + + distutils.command.build_ext.build_ext.__init__(self, *args, **kwargs) + def swig_sources(self, sources, extensions=None): if self.extensions is None: return @@ -49,7 +61,7 @@ class build_ext(distutils.command.build_ext.build_ext): def compile_qrc(self, name, source, target): """compile qt resource file""" - os.system("rcc -name %s -o %s %s" %(name, target, source)) + os.system("%s -name %s -o %s %s" %(self.rcc_binary, name, target, source)) def compile_mocs(self, moc_headers): targets = [] @@ -64,7 +76,7 @@ class build_ext(distutils.command.build_ext.build_ext): return targets def compile_moc(self, source, target): - os.system("moc -o%s %s" %(target, source)) + os.system("%s -o%s %s" %(self.moc_binary, target, source)) boost_py = ["py/conserved_path.cpp", "py/glsequence.cpp", @@ -136,32 +148,44 @@ qrc_sources = ['icons.qrc'] sources = boost_py+core_alg+moc_headers+qui_sources+qrc_sources + +extra_link_args = [] +libraries = ['boost_python', + 'boost_filesystem'] +include_dirs = ['.'] + +if sys.platform == 'darwin': + import py2app + qtroot = '/usr/local/qt/4.1.2' + qtincludes.os.path.join(qtroot, 'include') + extra_link_args.extend([ + '-F%s/lib' % (qtroot), + '-framework', 'QtCore', + '-framework', 'QtGui', + '-framework', 'QtOpenGL', + '-framework', 'OpenGL', + ]) +else: + qtroot = '/usr' + qtinclude = os.path.join(qtroot, 'include', 'qt4') + libraries += ['QtCore'] + libraries += ['QtGui'] + libraries += ['QtOpenGL'] + + + +for qtdir in ['','QtCore','QtGui','QtOpenGL']: + include_dirs.append(os.path.join(qtinclude, qtdir)) + mussa_ext = Extension("_mussa", sources, - include_dirs=[ - '/usr/include/boost', - '/usr/local/qt/4.1.2/include/', - '/usr/local/qt/4.1.2/include/QtCore', - '/usr/local/qt/4.1.2/include/QtGui', - '/usr/local/qt/4.1.2/include/QtOpenGL', - '.' - ], + include_dirs=include_dirs, library_dirs=[ - '/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/', + #'/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/', '/usr/local/qt/4.1.2/lib', ], - libraries=[ - 'boost_python', - 'boost_filesystem', - 'GL', - ], - extra_link_args = [ - '-F/usr/local/qt/4.1.2/lib', - '-framework', 'QtCore', - '-framework', 'QtGui', - '-framework', 'QtOpenGL', - '-framework', 'OpenGL', - ] + libraries=libraries, + extra_link_args = extra_link_args ) setup(app=['mussa.py'], name='mussa',