1 from setuptools import setup, Extension
2 import distutils.command.build_ext
3 from distutils.dep_util import newer
8 def replace_suffix(path, new_suffix):
9 return os.path.splitext(path)[0]+new_suffix
11 class build_ext(distutils.command.build_ext.build_ext):
12 description="also compile qt moc files"
14 def __init__(self, *args, **kwargs):
15 if sys.platform == 'linux2':
16 self.moc_binary = 'moc'
17 self.rcc_binary = 'rcc'
19 if os.path.exists('/usr/bin/moc-qt4'):
20 self.moc_binary = '/usr/bin/moc-qt4'
21 if os.path.exists('/usr/bin/rcc-qt4'):
22 self.rcc_binary = '/usr/bin/rcc-qt4'
24 distutils.command.build_ext.build_ext.__init__(self, *args, **kwargs)
26 def swig_sources(self, sources, extensions=None):
27 if self.extensions is None:
35 base,ext= os.path.splitext(src)
37 qrc_sources.append(src)
38 elif ext in ('.hpp', '.hxx', '.h'):
39 moc_sources.append(src)
41 other_sources.append(src)
43 build_sources = other_sources
45 build_sources.extend(self.compile_qrcs(qrc_sources))
47 build_sources.extend(self.compile_mocs(moc_sources))
50 def compile_qrcs(self, qrc_files):
53 if os.path.exists(qrc):
55 name = os.path.splitext(os.path.split(qrc)[1])[0]
56 target = "qrc_"+name+".cpp"
57 if newer(source, target) or self.force:
58 self.compile_qrc(name, source, target)
59 targets.append(target)
62 def compile_qrc(self, name, source, target):
63 """compile qt resource file"""
64 os.system("%s -name %s -o %s %s" %(self.rcc_binary, name, target, source))
66 def compile_mocs(self, moc_headers):
69 for moc_hpp in moc_headers:
70 if os.path.exists(moc_hpp):
72 target = "moc_"+replace_suffix(os.path.split(moc_hpp)[1],'.cpp')
73 if newer(source, target) or self.force:
74 self.compile_moc(source, target)
75 targets.append(target)
78 def compile_moc(self, source, target):
79 os.system("%s -o%s %s" %(self.moc_binary, target, source))
81 boost_py = ["py/conserved_path.cpp",
89 core_alg = ["alg/annotation_colors.cpp",
91 "alg/conserved_path.cpp",
93 "alg/flp_seqcomp.cpp",
94 "alg/glseqbrowser.cpp",
97 "alg/nway_entropy.cpp",
101 #"alg/parse_options.cpp",
104 moc_headers = ['qui/ImageSaveDialog.hpp',
105 'qui/ImageScaler.hpp',
107 'qui/MussaAlignedWindow.hpp',
108 'qui/MussaWindow.hpp',
109 'qui/ThresholdWidget.hpp',
110 'qui/ZoomWidget.hpp',
111 'qui/motif_editor/MotifDetail.hpp',
112 'qui/motif_editor/MotifEditor.hpp',
113 'qui/mussa_setup_dialog/IsFileValidator.hpp',
114 'qui/mussa_setup_dialog/MussaSetupDialog.hpp',
115 'qui/mussa_setup_dialog/MussaSetupWidget.hpp',
116 'qui/mussa_setup_dialog/SequenceSetupFrame.hpp',
117 'qui/mussa_setup_dialog/SequenceSetupWidget.hpp',
118 'qui/mussa_setup_dialog/SetupInfo.hpp',
119 'qui/seqbrowser/ScrollableSequenceBrowser.hpp',
120 'qui/seqbrowser/SequenceBrowser.hpp',
121 'qui/seqbrowser/SequenceBrowserSidebar.hpp',
122 'qui/seqbrowser/SequenceBrowserWidget.hpp',
123 'qui/seqbrowser/SequenceDescription.hpp',]
125 qui_sources = ['qui/ImageSaveDialog.cpp',
126 'qui/ImageScaler.cpp',
128 'qui/MussaAlignedWindow.cpp',
129 'qui/MussaWindow.cpp',
130 'qui/ThresholdWidget.cpp',
131 'qui/ZoomWidget.cpp',
132 'qui/motif_editor/MotifDetail.cpp',
133 'qui/motif_editor/MotifEditor.cpp',
134 'qui/mussa_setup_dialog/IsFileValidator.cpp',
135 'qui/mussa_setup_dialog/MussaSetupDialog.cpp',
136 'qui/mussa_setup_dialog/MussaSetupWidget.cpp',
137 'qui/mussa_setup_dialog/SequenceSetupFrame.cpp',
138 'qui/mussa_setup_dialog/SequenceSetupWidget.cpp',
139 'qui/mussa_setup_dialog/SetupInfo.cpp',
140 'qui/seqbrowser/ScrollableSequenceBrowser.cpp',
141 'qui/seqbrowser/SequenceBrowser.cpp',
142 'qui/seqbrowser/SequenceBrowserSidebar.cpp',
143 'qui/seqbrowser/SequenceBrowserWidget.cpp',
144 'qui/seqbrowser/SequenceDescription.cpp',
147 qrc_sources = ['icons.qrc']
149 sources = boost_py+core_alg+moc_headers+qui_sources+qrc_sources
153 libraries = ['boost_python',
157 if sys.platform == 'darwin':
159 qtroot = '/usr/local/qt/4.1.2'
160 qtincludes.os.path.join(qtroot, 'include')
161 extra_link_args.extend([
162 '-F%s/lib' % (qtroot),
163 '-framework', 'QtCore',
164 '-framework', 'QtGui',
165 '-framework', 'QtOpenGL',
166 '-framework', 'OpenGL',
170 qtinclude = os.path.join(qtroot, 'include', 'qt4')
171 libraries += ['QtCore']
172 libraries += ['QtGui']
173 libraries += ['QtOpenGL']
177 for qtdir in ['','QtCore','QtGui','QtOpenGL']:
178 include_dirs.append(os.path.join(qtinclude, qtdir))
180 mussa_ext = Extension("_mussa",
182 include_dirs=include_dirs,
184 #'/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/',
185 '/usr/local/qt/4.1.2/lib',
188 extra_link_args = extra_link_args
190 setup(app=['mussa.py'],
193 ext_modules=[mussa_ext],
194 cmdclass={'build_ext': build_ext})