| Trees | Indices | Help |
|
|---|
|
|
1 ###############################################################################
2 # #
3 # Copyright (C) 2011-2013 Edward d'Auvergne #
4 # #
5 # This file is part of the program relax (http://www.nmr-relax.com). #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 # Module docstring.
23 """This script is used to build relax as an application on certain platforms.
24
25 The Mac OS X component was initially generated by py2applet, but has been highly modified. To use this script to build a Mac app, the following command needs to be run:
26
27 Usage:
28
29 python setup.py py2app
30
31
32 To then create a DMG file for installation, type:
33
34 hdiutil create -fs HFS+ -volname "relax" -srcfolder dist/relax.app relax.dmg
35 """
36
37 # Python module import.
38 from os import getcwd, sep, walk
39 from os.path import relpath, sep
40 from re import search
41 try:
42 from setuptools import setup
43 except ImportError:
44 print("ImportError: To run setup.py, please installed the Python setuptools (see http://pypi.python.org/pypi/setuptools)")
45 setup = None
46 import sys
47
48 # relax module imports.
49 from lib.errors import RelaxError
50 from status import Status; status = Status()
51 from version import version_full
52
53
55 """Class containing setuptools targets for different platforms."""
56
58 """Initialise and execute."""
59
60 # The extension.
61 extension = sys.argv[1]
62
63 # Mac OS X application.
64 if extension == 'py2app':
65 self.mac_setup()
66
67 # Unsupported platform.
68 else:
69 raise RelaxError("The setuptools extension '%s' is not supported yet." % extension)
70
71 # Generic setup args.
72 self.args_generic()
73
74 # Execute the setuptools setup() method to actually do something.
75 setup(
76 app=self.APP,
77 name=self.NAME,
78 version=self.VERSION,
79 data_files=self.DATA_FILES,
80 options=self.OPTIONS,
81 setup_requires=self.REQUIRES
82 )
83
84
86 """Set up the arguments which are independent of the target."""
87
88 # Get a list of data files.
89 self.DATA_FILES = self.get_data_files()
90 #for i in range(len(self.DATA_FILES)):
91 # print(self.DATA_FILES[i])
92 #sys.exit(1)
93
94 # Get the includes.
95 self.INCLUDES = self.get_includes()
96 #for i in range(len(self.INCLUDES)):
97 # print(self.INCLUDES[i])
98 #sys.exit(1)
99
100
102 """Collect and return a list of data files.
103
104 @return: The list of data files as full paths.
105 @rtype: list of str
106 """
107
108 # Blacklisted files and directories.
109 blacklist_dir = [
110 'build',
111 'dist'
112 ]
113 blacklist_files = [
114 ]
115
116 # All files and directories.
117 data_files = []
118 cwd = getcwd()
119 for (dirpath, dirnames, filenames) in walk(cwd):
120 # Skip .svn directories.
121 split_path = dirpath.split(sep)
122 if '.svn' in split_path:
123 continue
124
125 # Skip blacklisted directories.
126 skip = False
127 for dir_name in blacklist_dir:
128 if dir_name in split_path:
129 skip = True
130 if skip:
131 continue
132
133 # The relative path.
134 rel_path = relpath(dirpath, cwd)
135
136 # Loop over the files.
137 file_list = []
138 for file in filenames:
139 # Skip names starting with '.'.
140 if search('^\.', file):
141 continue
142
143 # Blacklist.
144 if file in blacklist_files:
145 continue
146
147 # Append the file with path to the list.
148 file_list.append("%s%s%s" % (rel_path, sep, file))
149
150 # Append a tuple of the destination directory and the files.
151 data_files.append((rel_path, file_list))
152
153 # Return the data files.
154 return data_files
155
156
158 """Collect and return a list of modules to include.
159
160 @return: The list of modules.
161 @rtype: list of str
162 """
163
164 # Blacklisted files and directories.
165 blacklist_dir = [
166 'build',
167 'dist',
168 'bmrblib'+sep+'html_dictionary',
169 'graphics',
170 'sample_scripts',
171 'scripts',
172 'test_suite'+sep+'system_tests'+sep+'scripts',
173 'test_suite'+sep+'shared_data'
174 ]
175 blacklist_files = [
176 ]
177
178 # All files and directories.
179 includes = []
180 cwd = getcwd()
181 for (dirpath, dirnames, filenames) in walk(cwd):
182 # Skip .svn directories.
183 split_path = dirpath.split(sep)
184 if '.svn' in split_path:
185 continue
186
187 # The relative path.
188 rel_path = relpath(dirpath, cwd)
189
190 # Skip blacklisted directories.
191 skip = False
192 for dir_name in blacklist_dir:
193 if search(dir_name, rel_path):
194 skip = True
195 if skip:
196 continue
197
198 # The module path.
199 if rel_path == '.':
200 module_path = ''
201 else:
202 module_path = rel_path.replace(sep, '.')
203 if module_path:
204 module_path += '.'
205
206 # Loop over the files.
207 for file in filenames:
208 # Skip names starting with '.'.
209 if search('^\.', file):
210 continue
211
212 # Skip non-Python source files.
213 if not search('\.py$', file):
214 continue
215
216 # Blacklist.
217 if file in blacklist_files:
218 continue
219
220 # Append a tuple of the destination directory and the file.
221 includes.append("%s%s" % (module_path, file[:-3]))
222
223 # Return the data files.
224 return includes
225
226
228 """Mac OS X setup."""
229
230 # The relax settings.
231 self.APP = ['relax_gui_mode.py']
232 self.NAME = 'relax'
233 self.VERSION = version_full()
234 self.OPTIONS = {}
235 self.OPTIONS['py2app'] = {
236 'argv_emulation': False,
237 'iconfile': status.install_path + sep + 'graphics' + sep + 'ulysses_shadowless_trans_128x128.icns',
238 'packages': 'wx',
239 'site_packages': True,
240 'includes': self.get_includes(),
241 'excludes': ['build', 'dist'],
242 'plist': {
243 'CFBundleName': 'relax',
244 'CFBundleShortVersionString': version_full(),
245 'CFBundleGetInfoString': 'relax %s' % version_full(),
246 'CFBundleIdentifier': 'com.nmr-relax.relax'
247 }
248 }
249 self.REQUIRES = ['py2app']
250
251
252 # Execute the main class.
253 if __name__ == '__main__':
254 Setup()
255
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Nov 26 19:05:09 2013 | http://epydoc.sourceforge.net |