view setup.py @ 2430:ec146907c4c3
Fix typo attr -> attrs
| author |
Cédric Krier <ced@b2ck.com> |
| date |
Tue, 11 Dec 2012 22:34:50 +0100 |
| parents |
c951166dd01a |
| children |
e5cdaf0a7ba1 |
line source
2 #This file is part of Tryton. The COPYRIGHT file at the top level of
3 #this repository contains the full copyright notices and license terms.
5 from setuptools import setup, find_packages
13 return open(os.path.join(os.path.dirname(__file__), fname)).read()
18 from babel.messages import frontend as babel
21 'compile_catalog': babel.compile_catalog,
22 'extract_messages': babel.extract_messages,
23 'init_catalog': babel.init_catalog,
24 'update_catalog': babel.update_catalog,
27 args['message_extractors'] = {
29 ('**.py', 'python', None),
54 for lang in languages:
56 yield lang.split('_')[0]
59 ('share/pixmaps/tryton', glob.glob('share/pixmaps/tryton/*.png') + \
60 glob.glob('share/pixmaps/tryton/*.svg')),
62 for lang in languages:
64 ('share/locale/%s/LC_MESSAGES' % lang,
65 glob.glob('share/locale/%s/LC_MESSAGES/*.mo' % lang)),
72 'script': os.path.join('bin', 'tryton'),
74 (1, os.path.join('share', 'pixmaps', 'tryton', 'tryton.ico'))],
79 'bundle_files': 3, # don't bundle because gtk doesn't support it
91 args['zipfile'] = 'library.zip'
93 data_files.append(('', ['msvcr90.dll', 'msvcp90.dll', 'msvcm90.dll']))
94 manifest = read('Microsoft.VC90.CRT.manifest')
95 args['windows'][0]['other_resources'] = [(24, 1, manifest)]
98 elif sys.platform == 'darwin':
100 from modulegraph.find_modules import PY_SUFFIXES
101 PY_SUFFIXES.append('')
102 args['app'] = [os.path.join('bin', 'tryton')]
105 'argv_emulation': True,
106 'includes': 'pygtk, gtk, glib, cairo, pango, pangocairo, atk, ' \
107 'gobject, gio, gtk.keysyms',
108 'resources': 'tryton/plugins',
109 'frameworks': 'librsvg-2.2.dylib',
111 'CFBundleIdentifier': 'org.tryton',
112 'CFBundleName': 'Tryton',
114 'iconfile': os.path.join('share', 'pixmaps', 'tryton',
119 execfile(os.path.join('tryton', 'version.py'))
122 if sys.version_info < (2, 7):
123 WEAKREF = ['weakrefset']
125 dist = setup(name=PACKAGE,
127 description='Tryton client',
128 long_description=read('README'),
131 download_url="http://downloads.tryton.org/" + \
132 VERSION.rsplit('.', 1)[0] + '/',
133 packages=find_packages(),
134 data_files=data_files,
135 scripts=['bin/tryton'],
137 'Development Status :: 5 - Production/Stable',
138 'Environment :: X11 Applications :: GTK',
139 'Framework :: Tryton',
140 'Intended Audience :: End Users/Desktop',
141 'License :: OSI Approved :: GNU General Public License (GPL)',
142 'Natural Language :: Bulgarian',
143 'Natural Language :: Catalan',
144 'Natural Language :: Czech',
145 'Natural Language :: Dutch',
146 'Natural Language :: English',
147 'Natural Language :: French',
148 'Natural Language :: German',
149 'Natural Language :: Russian',
150 'Natural Language :: Spanish',
151 'Natural Language :: Slovak',
152 'Natural Language :: Slovenian',
153 'Natural Language :: Japanese',
154 'Operating System :: OS Independent',
155 'Programming Language :: Python :: 2.6',
156 'Programming Language :: Python :: 2.7',
157 'Topic :: Office/Business',
165 'timezone': ['pytz'],
166 'simplejson': ['simplejson'],
167 'cdecimal': ['cdecimal'],
174 for directory in os.environ['PATH'].split(';'):
175 if not os.path.isdir(directory):
177 for file in ('gtk-demo.exe', 'gdk-pixbuf-query-loaders.exe'):
178 if os.path.isfile(os.path.join(directory, file)):
179 return os.path.dirname(directory)
183 default_path = os.path.join(os.environ['PROGRAMFILES'], 'NSIS')
184 for directory in os.environ['PATH'].split(';') + [default_path]:
185 if not os.path.isdir(directory):
187 path = os.path.join(directory, 'makensis.exe')
188 if os.path.isfile(path):
192 if 'py2exe' in dist.commands:
197 gtk_dir = find_gtk_dir()
199 dist_dir = dist.command_obj['py2exe'].dist_dir
201 # pytz installs the zoneinfo directory tree in the same directory
202 # Make sure the layout of pytz hasn't changed
203 assert (pytz.__file__.endswith('__init__.pyc') or
204 pytz.__file__.endswith('__init__.py')), pytz.__file__
205 zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
206 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
207 zipfile_path = os.path.join(dist_dir, 'library.zip')
208 z = zipfile.ZipFile(zipfile_path, 'a')
209 for absdir, directories, filenames in os.walk(zoneinfo_dir):
210 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
211 zip_dir = absdir[len(disk_basedir):]
213 z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))
216 if os.path.isdir(os.path.join(dist_dir, 'plugins')):
217 shutil.rmtree(os.path.join(dist_dir, 'plugins'))
218 shutil.copytree(os.path.join(os.path.dirname(__file__), 'tryton',
219 'plugins'), os.path.join(dist_dir, 'plugins'))
221 if os.path.isdir(os.path.join(dist_dir, 'etc')):
222 shutil.rmtree(os.path.join(dist_dir, 'etc'))
223 shutil.copytree(os.path.join(gtk_dir, 'etc'),
224 os.path.join(dist_dir, 'etc'))
226 from subprocess import Popen, PIPE
227 query_loaders = Popen(os.path.join(gtk_dir, 'bin',
228 'gdk-pixbuf-query-loaders'), stdout=PIPE).stdout.read()
229 query_loaders = query_loaders.replace(
230 gtk_dir.replace(os.sep, '/') + '/', '')
232 loaders_path = os.path.join(dist_dir, 'etc', 'gtk-2.0',
233 'gdk-pixbuf.loaders')
234 with open(loaders_path, 'w') as loaders:
235 loaders.writelines([line + "\n" for line in
236 query_loaders.split(os.linesep)])
238 if os.path.isdir(os.path.join(dist_dir, 'lib')):
239 shutil.rmtree(os.path.join(dist_dir, 'lib'))
240 shutil.copytree(os.path.join(gtk_dir, 'lib'),
241 os.path.join(dist_dir, 'lib'))
243 for file in glob.iglob(os.path.join(gtk_dir, 'bin', '*.dll')):
244 if os.path.isfile(file):
245 shutil.copy(file, dist_dir)
247 for lang in all_languages():
248 if os.path.isdir(os.path.join(dist_dir, 'share', 'locale', lang)):
249 shutil.rmtree(os.path.join(dist_dir, 'share', 'locale', lang))
250 if os.path.isdir(os.path.join(gtk_dir, 'share', 'locale', lang)):
251 shutil.copytree(os.path.join(gtk_dir, 'share', 'locale', lang),
252 os.path.join(dist_dir, 'share', 'locale', lang))
254 if os.path.isdir(os.path.join(dist_dir, 'share', 'themes',
256 shutil.rmtree(os.path.join(dist_dir, 'share', 'themes',
258 shutil.copytree(os.path.join(gtk_dir, 'share', 'themes', 'MS-Windows'),
259 os.path.join(dist_dir, 'share', 'themes', 'MS-Windows'))
261 makensis = find_makensis()
263 from subprocess import Popen
264 Popen([makensis, "/DVERSION=" + VERSION,
265 str(os.path.join(os.path.dirname(__file__),
266 'setup.nsi'))]).wait()
267 Popen([makensis, "/DVERSION=" + VERSION,
268 str(os.path.join(os.path.dirname(__file__),
269 'setup-single.nsi'))]).wait()
271 print "makensis.exe not found: installers can not be created, "\
272 "skip setup.nsi and setup-single.nsi"
273 elif sys.platform == 'darwin':
276 for directory in os.environ['PATH'].split(':'):
277 if not os.path.isdir(directory):
279 for file in ('gtk-demo',):
280 if os.path.isfile(os.path.join(directory, file)):
281 return os.path.dirname(directory)
284 if 'py2app' in dist.commands:
286 from subprocess import Popen, PIPE
287 from itertools import chain
288 from glob import iglob
289 gtk_dir = find_gtk_dir()
290 gtk_binary_version = Popen(['pkg-config',
291 '--variable=gtk_binary_version', 'gtk+-2.0'],
292 stdout=PIPE).stdout.read().strip()
294 dist_dir = dist.command_obj['py2app'].dist_dir
295 resources_dir = os.path.join(dist_dir, 'Tryton.app', 'Contents',
297 gtk_2_dist_dir = os.path.join(resources_dir, 'lib', 'gtk-2.0')
298 pango_dist_dir = os.path.join(resources_dir, 'lib', 'pango')
300 if os.path.isdir(pango_dist_dir):
301 shutil.rmtree(pango_dist_dir)
302 shutil.copytree(os.path.join(gtk_dir, 'lib', 'pango'), pango_dist_dir)
304 query_pango = Popen(os.path.join(gtk_dir, 'bin', 'pango-querymodules'),
305 stdout=PIPE).stdout.read()
306 query_pango = query_pango.replace(gtk_dir,
307 '@executable_path/../Resources')
308 pango_modules_path = os.path.join(resources_dir, 'pango.modules')
309 with open(pango_modules_path, 'w') as pango_modules:
310 pango_modules.write(query_pango)
312 with open(os.path.join(resources_dir, 'pangorc'), 'w') as pangorc:
313 pangorc.write('[Pango]\n')
314 pangorc.write('ModuleFiles=./pango.modules\n')
316 if not os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version,
318 os.makedirs(os.path.join(gtk_2_dist_dir, gtk_binary_version,
320 shutil.copyfile(os.path.join(gtk_dir, 'lib', 'gtk-2.0',
321 gtk_binary_version, 'engines', 'libclearlooks.so'),
322 os.path.join(gtk_2_dist_dir, gtk_binary_version, 'engines',
325 query_loaders = Popen(os.path.join(gtk_dir, 'bin',
326 'gdk-pixbuf-query-loaders'), stdout=PIPE).stdout.read()
327 loader_dir, = re.findall('# LoaderDir = (.*)', query_loaders)
328 loader_pkg = (loader_dir.replace(os.path.join(gtk_dir, 'lib'),
329 '').split(os.path.sep)[-3])
330 loader_dist_dir = os.path.join(resources_dir, 'lib', loader_pkg,
331 gtk_binary_version, 'loaders')
332 if os.path.isdir(loader_dist_dir):
333 shutil.rmtree(loader_dist_dir)
334 if os.path.isdir(loader_dir):
335 shutil.copytree(loader_dir, loader_dist_dir)
336 query_loaders = query_loaders.replace(gtk_dir,
337 '@executable_path/../Resources')
339 loaders_path = os.path.join(resources_dir, 'gdk-pixbuf.loaders')
340 with open(loaders_path, 'w') as loaders:
341 loaders.write(query_loaders)
343 if os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version,
345 shutil.rmtree(os.path.join(gtk_2_dist_dir, gtk_binary_version,
347 shutil.copytree(os.path.join(gtk_dir, 'lib', 'gtk-2.0',
348 gtk_binary_version, 'immodules'), os.path.join(gtk_2_dist_dir,
349 gtk_binary_version, 'immodules'))
351 query_immodules = Popen(os.path.join(gtk_dir, 'bin',
352 'gtk-query-immodules-2.0'), stdout=PIPE).stdout.read()
353 query_immodules = query_immodules.replace(gtk_dir,
354 '@executable_path/../Resources')
356 immodules_path = os.path.join(resources_dir, 'gtk.immodules')
357 with open(immodules_path, 'w') as immodules:
358 immodules.write(query_immodules)
360 shutil.copy(os.path.join(gtk_dir, 'share', 'themes', 'Clearlooks',
361 'gtk-2.0', 'gtkrc'), os.path.join(resources_dir, 'gtkrc'))
363 for lang in all_languages():
364 if os.path.isdir(os.path.join(resources_dir, 'share', 'locale',
366 shutil.rmtree(os.path.join(resources_dir, 'share', 'locale',
368 if os.path.isdir(os.path.join(gtk_dir, 'share', 'locale', lang)):
369 shutil.copytree(os.path.join(gtk_dir, 'share', 'locale', lang),
370 os.path.join(resources_dir, 'share', 'locale', lang))
372 # fix pathes within shared libraries
373 for library in chain(
374 iglob(os.path.join(loader_dist_dir, '*.so')),
375 iglob(os.path.join(gtk_2_dist_dir, gtk_binary_version,
377 iglob(os.path.join(gtk_2_dist_dir, gtk_binary_version,
378 'immodules', '*.so')),
379 iglob(os.path.join(pango_dist_dir, '*', 'modules', '*.so'))):
380 libs = [lib.split('(')[0].strip()
381 for lib in Popen(['otool', '-L', library],
382 stdout=PIPE).communicate()[0].splitlines()
383 if 'compatibility' in lib]
384 libs = dict(((lib, None) for lib in libs if gtk_dir in lib))
385 for lib in libs.keys():
386 fixed = lib.replace(gtk_dir + '/lib',
387 '@executable_path/../Frameworks')
388 Popen(['install_name_tool', '-change', lib, fixed,
391 for file in ('CHANGELOG', 'COPYRIGHT', 'LICENSE', 'README', 'TODO'):
392 shutil.copyfile(os.path.join(os.path.dirname(__file__), file),
393 os.path.join(dist_dir, file + '.txt'))
395 doc_dist_dir = os.path.join(dist_dir, 'doc')
396 if os.path.isdir(doc_dist_dir):
397 shutil.rmtree(doc_dist_dir)
398 shutil.copytree(os.path.join(os.path.dirname(__file__), 'doc'),
401 dmg_file = os.path.join(os.path.dirname(__file__), 'tryton-' + VERSION
403 if os.path.isfile(dmg_file):
405 Popen(['hdiutil', 'create', dmg_file, '-volname', 'Tryton Client ' +
406 VERSION, '-fs', 'HFS+', '-srcfolder', dist_dir]).wait()