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 swig_sources(self, sources, extensions=None):
15 if self.extensions is None:
23 base,ext= os.path.splitext(src)
25 qrc_sources.append(src)
26 elif ext in ('.hpp', '.hxx', '.h'):
27 moc_sources.append(src)
29 other_sources.append(src)
31 build_sources = other_sources
33 build_sources.extend(self.compile_qrcs(qrc_sources))
35 build_sources.extend(self.compile_mocs(moc_sources))
38 def compile_qrcs(self, qrc_files):
41 if os.path.exists(qrc):
43 name = os.path.splitext(os.path.split(qrc)[1])[0]
44 target = "qrc_"+name+".cpp"
45 if newer(source, target) or self.force:
46 self.compile_qrc(name, source, target)
47 targets.append(target)
50 def compile_qrc(self, name, source, target):
51 """compile qt resource file"""
52 os.system("rcc -name %s -o %s %s" %(name, target, source))
54 def compile_mocs(self, moc_headers):
57 for moc_hpp in moc_headers:
58 if os.path.exists(moc_hpp):
60 target = "moc_"+replace_suffix(os.path.split(moc_hpp)[1],'.cpp')
61 if newer(source, target) or self.force:
62 self.compile_moc(source, target)
63 targets.append(target)
66 def compile_moc(self, source, target):
67 os.system("moc -o%s %s" %(target, source))
69 boost_py = ["py/conserved_path.cpp",
77 core_alg = ["alg/annotation_colors.cpp",
79 "alg/conserved_path.cpp",
81 "alg/flp_seqcomp.cpp",
82 "alg/glseqbrowser.cpp",
85 "alg/nway_entropy.cpp",
89 #"alg/parse_options.cpp",
92 moc_headers = ['qui/ImageSaveDialog.hpp',
93 'qui/ImageScaler.hpp',
95 'qui/MussaAlignedWindow.hpp',
96 'qui/MussaWindow.hpp',
97 'qui/ThresholdWidget.hpp',
99 'qui/motif_editor/MotifDetail.hpp',
100 'qui/motif_editor/MotifEditor.hpp',
101 'qui/mussa_setup_dialog/IsFileValidator.hpp',
102 'qui/mussa_setup_dialog/MussaSetupDialog.hpp',
103 'qui/mussa_setup_dialog/MussaSetupWidget.hpp',
104 'qui/mussa_setup_dialog/SequenceSetupFrame.hpp',
105 'qui/mussa_setup_dialog/SequenceSetupWidget.hpp',
106 'qui/mussa_setup_dialog/SetupInfo.hpp',
107 'qui/seqbrowser/ScrollableSequenceBrowser.hpp',
108 'qui/seqbrowser/SequenceBrowser.hpp',
109 'qui/seqbrowser/SequenceBrowserSidebar.hpp',
110 'qui/seqbrowser/SequenceBrowserWidget.hpp',
111 'qui/seqbrowser/SequenceDescription.hpp',]
113 qui_sources = ['qui/ImageSaveDialog.cpp',
114 'qui/ImageScaler.cpp',
116 'qui/MussaAlignedWindow.cpp',
117 'qui/MussaWindow.cpp',
118 'qui/ThresholdWidget.cpp',
119 'qui/ZoomWidget.cpp',
120 'qui/motif_editor/MotifDetail.cpp',
121 'qui/motif_editor/MotifEditor.cpp',
122 'qui/mussa_setup_dialog/IsFileValidator.cpp',
123 'qui/mussa_setup_dialog/MussaSetupDialog.cpp',
124 'qui/mussa_setup_dialog/MussaSetupWidget.cpp',
125 'qui/mussa_setup_dialog/SequenceSetupFrame.cpp',
126 'qui/mussa_setup_dialog/SequenceSetupWidget.cpp',
127 'qui/mussa_setup_dialog/SetupInfo.cpp',
128 'qui/seqbrowser/ScrollableSequenceBrowser.cpp',
129 'qui/seqbrowser/SequenceBrowser.cpp',
130 'qui/seqbrowser/SequenceBrowserSidebar.cpp',
131 'qui/seqbrowser/SequenceBrowserWidget.cpp',
132 'qui/seqbrowser/SequenceDescription.cpp',
135 qrc_sources = ['icons.qrc']
137 sources = boost_py+core_alg+moc_headers+qui_sources+qrc_sources
139 mussa_ext = Extension("_mussa",
142 '/usr/include/boost',
143 '/usr/local/qt/4.1.2/include/',
144 '/usr/local/qt/4.1.2/include/QtCore',
145 '/usr/local/qt/4.1.2/include/QtGui',
146 '/usr/local/qt/4.1.2/include/QtOpenGL',
150 '/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/',
151 '/usr/local/qt/4.1.2/lib',
159 '-F/usr/local/qt/4.1.2/lib',
160 '-framework', 'QtCore',
161 '-framework', 'QtGui',
162 '-framework', 'QtOpenGL',
163 '-framework', 'OpenGL',
166 setup(app=['mussa.py'],
169 ext_modules=[mussa_ext],
170 cmdclass={'build_ext': build_ext})