| Trees | Indices | Help |
|
|---|
|
|
1 ###############################################################################
2 # #
3 # Copyright (C) 2011-2012 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 .git directories.
121 split_path = dirpath.split(sep)
122 if '.git' 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(r'^\.', 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 # Whitelisted directories.
179 whitelist_dir = [
180 'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam'
181 ]
182
183 # All files and directories.
184 includes = []
185 cwd = getcwd()
186 for (dirpath, dirnames, filenames) in walk(cwd):
187 # Skip .git directories.
188 split_path = dirpath.split(sep)
189 if '.git' in split_path:
190 continue
191
192 # The relative path.
193 rel_path = relpath(dirpath, cwd)
194
195 # Skip blacklisted directories.
196 skip = False
197 for dir_name in blacklist_dir:
198 if search(dir_name, rel_path) and rel_path not in whitelist_dir:
199 skip = True
200 if skip:
201 continue
202
203 # The module path.
204 if rel_path == '.':
205 module_path = ''
206 else:
207 module_path = rel_path.replace(sep, '.')
208 if module_path:
209 module_path += '.'
210
211 # Loop over the files.
212 for file in filenames:
213 # Skip names starting with '.'.
214 if search(r'^\.', file):
215 continue
216
217 # Skip non-Python source files.
218 if not search(r'\.py$', file):
219 continue
220
221 # Blacklist.
222 if file in blacklist_files:
223 continue
224
225 # Append a tuple of the destination directory and the file.
226 includes.append("%s%s" % (module_path, file[:-3]))
227
228 # Return the data files.
229 return includes
230
231
233 """Mac OS X setup."""
234
235 # The relax settings.
236 self.APP = ['relax_gui_mode.py']
237 self.NAME = 'relax'
238 self.VERSION = version_full()
239 self.OPTIONS = {}
240 self.OPTIONS['py2app'] = {
241 'argv_emulation': False,
242 'iconfile': status.install_path + sep + 'graphics' + sep + 'ulysses_shadowless_trans_128x128.icns',
243 'packages': 'wx',
244 'site_packages': True,
245 'includes': self.get_includes(),
246 'excludes': ['build', 'dist'],
247 'plist': {
248 'CFBundleName': 'relax',
249 'CFBundleShortVersionString': version_full(),
250 'CFBundleGetInfoString': 'relax %s' % version_full(),
251 'CFBundleIdentifier': 'com.nmr-relax.relax'
252 }
253 }
254 self.REQUIRES = ['py2app']
255
256
257 # Execute the main class.
258 if __name__ == '__main__':
259 Setup()
260
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Jun 8 10:45:06 2024 | http://epydoc.sourceforge.net |