1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
|
#!/usr/bin/env python
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from setuptools import setup, find_packages
import os
import glob
import sys
import re
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {}
try:
from babel.messages import frontend as babel
args['cmdclass'] = {
'compile_catalog': babel.compile_catalog,
'extract_messages': babel.extract_messages,
'init_catalog': babel.init_catalog,
'update_catalog': babel.update_catalog,
}
args['message_extractors'] = {
'tryton': [
('**.py', 'python', None),
],
}
except ImportError:
pass
languages = (
'bg_BG',
'ca_ES',
'cs_CZ',
'de_DE',
'es_AR',
'es_CO',
'es_EC',
'es_ES',
'fr_FR',
'ja_JP',
'lt_LT',
'nl_NL',
'ru_RU',
'sl_SI',
)
def all_languages():
for lang in languages:
yield lang
yield lang.split('_')[0]
data_files = [
('share/icons/tryton', glob.glob('share/pixmaps/tryton/*.png') +
glob.glob('share/pixmaps/tryton/*.svg')),
('share/locale', ['share/locale/tryton.pot']),
]
for lang in languages:
data_files += [
('share/locale/%s/LC_MESSAGES' % lang,
glob.glob('share/locale/%s/LC_MESSAGES/*.mo' % lang) +
glob.glob('share/locale/%s/LC_MESSAGES/*.po' % lang)),
]
if os.name == 'nt':
import py2exe
args['windows'] = [{
'script': os.path.join('bin', 'tryton'),
'icon_resources': [
(1, os.path.join('share', 'pixmaps', 'tryton', 'tryton.ico'))],
}]
args['options'] = {
'py2exe': {
'optimize': 0,
'bundle_files': 3, # don't bundle because gtk doesn't support it
'packages': [
'encodings',
'gtk',
'pytz',
'atk',
'pango',
'pangocairo',
'gio',
],
}
}
args['zipfile'] = 'library.zip'
data_files.append(('', ['msvcr90.dll', 'msvcp90.dll', 'msvcm90.dll']))
manifest = read('Microsoft.VC90.CRT.manifest')
args['windows'][0]['other_resources'] = [(24, 1, manifest)]
elif sys.platform == 'darwin':
import py2app
from modulegraph.find_modules import PY_SUFFIXES
PY_SUFFIXES.append('')
args['app'] = [os.path.join('bin', 'tryton')]
args['options'] = {
'py2app': {
'argv_emulation': True,
'includes': ('pygtk, gtk, glib, cairo, pango, pangocairo, atk, '
'gobject, gio, gtk.keysyms'),
'resources': 'tryton/plugins',
'frameworks': 'librsvg-2.2.dylib',
'plist': {
'CFBundleIdentifier': 'org.tryton',
'CFBundleName': 'Tryton',
},
'iconfile': os.path.join('share', 'pixmaps', 'tryton',
'tryton.icns'),
},
}
PACKAGE, VERSION, LICENSE, WEBSITE = None, None, None, None
execfile(os.path.join('tryton', 'version.py'))
major_version, minor_version, _ = VERSION.split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
download_url = 'http://downloads.tryton.org/%s.%s/' % (
major_version, minor_version)
if minor_version % 2:
VERSION = '%s.%s.dev0' % (major_version, minor_version)
download_url = 'hg+http://hg.tryton.org/%s#egg=%s-%s' % (
PACKAGE, PACKAGE, VERSION)
dist = setup(name=PACKAGE,
version=VERSION,
description='Tryton client',
long_description=read('README'),
author='Tryton',
author_email='issue_tracker@tryton.org',
url=WEBSITE,
download_url=download_url,
keywords='business application ERP',
packages=find_packages(),
data_files=data_files,
scripts=['bin/tryton'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: X11 Applications :: GTK',
'Framework :: Tryton',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: Bulgarian',
'Natural Language :: Catalan',
'Natural Language :: Czech',
'Natural Language :: Dutch',
'Natural Language :: English',
'Natural Language :: French',
'Natural Language :: German',
'Natural Language :: Russian',
'Natural Language :: Spanish',
'Natural Language :: Slovak',
'Natural Language :: Slovenian',
'Natural Language :: Japanese',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Topic :: Office/Business',
],
platforms='any',
license=LICENSE,
install_requires=[
#"pygtk >= 2.6",
"python-dateutil",
],
extras_require={
'simplejson': ['simplejson'],
'cdecimal': ['cdecimal'],
'calendar': ['GooCalendar'],
},
zip_safe=False,
**args
)
if os.name == 'nt':
def find_gtk_dir():
for directory in os.environ['PATH'].split(';'):
if not os.path.isdir(directory):
continue
for file in ('gtk-demo.exe', 'gdk-pixbuf-query-loaders.exe'):
if os.path.isfile(os.path.join(directory, file)):
return os.path.dirname(directory)
return None
def find_makensis():
default_path = os.path.join(os.environ['PROGRAMFILES'], 'NSIS')
for directory in os.environ['PATH'].split(';') + [default_path]:
if not os.path.isdir(directory):
continue
path = os.path.join(directory, 'makensis.exe')
if os.path.isfile(path):
return path
return None
if 'py2exe' in dist.commands:
import shutil
import pytz
import zipfile
gtk_dir = find_gtk_dir()
dist_dir = dist.command_obj['py2exe'].dist_dir
# pytz installs the zoneinfo directory tree in the same directory
# Make sure the layout of pytz hasn't changed
assert (pytz.__file__.endswith('__init__.pyc') or
pytz.__file__.endswith('__init__.py')), pytz.__file__
zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
zipfile_path = os.path.join(dist_dir, 'library.zip')
z = zipfile.ZipFile(zipfile_path, 'a')
for absdir, directories, filenames in os.walk(zoneinfo_dir):
assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
zip_dir = absdir[len(disk_basedir):]
for f in filenames:
z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))
z.close()
if os.path.isdir(os.path.join(dist_dir, 'plugins')):
shutil.rmtree(os.path.join(dist_dir, 'plugins'))
shutil.copytree(os.path.join(os.path.dirname(__file__), 'tryton',
'plugins'), os.path.join(dist_dir, 'plugins'))
if os.path.isdir(os.path.join(dist_dir, 'etc')):
shutil.rmtree(os.path.join(dist_dir, 'etc'))
shutil.copytree(os.path.join(gtk_dir, 'etc'),
os.path.join(dist_dir, 'etc'))
from subprocess import Popen, PIPE
query_loaders = Popen(os.path.join(gtk_dir, 'bin',
'gdk-pixbuf-query-loaders'), stdout=PIPE).stdout.read()
query_loaders = query_loaders.replace(
gtk_dir.replace(os.sep, '/') + '/', '')
loaders_path = os.path.join(dist_dir, 'etc', 'gtk-2.0',
'gdk-pixbuf.loaders')
with open(loaders_path, 'w') as loaders:
loaders.writelines([line + "\n" for line in
query_loaders.split(os.linesep)])
if os.path.isdir(os.path.join(dist_dir, 'lib')):
shutil.rmtree(os.path.join(dist_dir, 'lib'))
shutil.copytree(os.path.join(gtk_dir, 'lib'),
os.path.join(dist_dir, 'lib'))
for file in glob.iglob(os.path.join(gtk_dir, 'bin', '*.dll')):
if os.path.isfile(file):
shutil.copy(file, dist_dir)
for lang in all_languages():
if os.path.isdir(os.path.join(dist_dir, 'share', 'locale', lang)):
shutil.rmtree(os.path.join(dist_dir, 'share', 'locale', lang))
if os.path.isdir(os.path.join(gtk_dir, 'share', 'locale', lang)):
shutil.copytree(os.path.join(gtk_dir, 'share', 'locale', lang),
os.path.join(dist_dir, 'share', 'locale', lang))
if os.path.isdir(os.path.join(os.path.dirname(__file__),
'share', 'locale', lang)):
shutil.copytree(os.path.join(os.path.dirname(__file__),
'share', 'locale', lang),
os.path.join(dist_dir, 'share', 'locale', lang))
if os.path.isdir(os.path.join(dist_dir, 'share', 'themes',
'MS-Windows')):
shutil.rmtree(os.path.join(dist_dir, 'share', 'themes',
'MS-Windows'))
shutil.copytree(os.path.join(gtk_dir, 'share', 'themes', 'MS-Windows'),
os.path.join(dist_dir, 'share', 'themes', 'MS-Windows'))
makensis = find_makensis()
if makensis:
from subprocess import Popen
Popen([makensis, "/DVERSION=" + VERSION,
str(os.path.join(os.path.dirname(__file__),
'setup.nsi'))]).wait()
Popen([makensis, "/DVERSION=" + VERSION,
str(os.path.join(os.path.dirname(__file__),
'setup-single.nsi'))]).wait()
else:
print "makensis.exe not found: installers can not be created, "\
"skip setup.nsi and setup-single.nsi"
elif sys.platform == 'darwin':
def find_gtk_dir():
for directory in os.environ['PATH'].split(':'):
if not os.path.isdir(directory):
continue
for file in ('gtk-demo',):
if os.path.isfile(os.path.join(directory, file)):
return os.path.dirname(directory)
return None
if 'py2app' in dist.commands:
import shutil
from subprocess import Popen, PIPE
from itertools import chain
from glob import iglob
gtk_dir = find_gtk_dir()
gtk_binary_version = Popen(['pkg-config',
'--variable=gtk_binary_version', 'gtk+-2.0'],
stdout=PIPE).stdout.read().strip()
dist_dir = dist.command_obj['py2app'].dist_dir
resources_dir = os.path.join(dist_dir, 'Tryton.app', 'Contents',
'Resources')
gtk_2_dist_dir = os.path.join(resources_dir, 'lib', 'gtk-2.0')
pango_dist_dir = os.path.join(resources_dir, 'lib', 'pango')
if os.path.isdir(pango_dist_dir):
shutil.rmtree(pango_dist_dir)
shutil.copytree(os.path.join(gtk_dir, 'lib', 'pango'), pango_dist_dir)
query_pango = Popen(os.path.join(gtk_dir, 'bin', 'pango-querymodules'),
stdout=PIPE).stdout.read()
query_pango = query_pango.replace(gtk_dir,
'@executable_path/../Resources')
pango_modules_path = os.path.join(resources_dir, 'pango.modules')
with open(pango_modules_path, 'w') as pango_modules:
pango_modules.write(query_pango)
with open(os.path.join(resources_dir, 'pangorc'), 'w') as pangorc:
pangorc.write('[Pango]\n')
pangorc.write('ModuleFiles=./pango.modules\n')
if not os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'engines')):
os.makedirs(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'engines'))
shutil.copyfile(os.path.join(gtk_dir, 'lib', 'gtk-2.0',
gtk_binary_version, 'engines', 'libclearlooks.so'),
os.path.join(gtk_2_dist_dir, gtk_binary_version, 'engines',
'libclearlooks.so'))
query_loaders = Popen(os.path.join(gtk_dir, 'bin',
'gdk-pixbuf-query-loaders'), stdout=PIPE).stdout.read()
loader_dir, = re.findall('# LoaderDir = (.*)', query_loaders)
loader_pkg = (loader_dir.replace(os.path.join(gtk_dir, 'lib'),
'').split(os.path.sep)[-3])
loader_dist_dir = os.path.join(resources_dir, 'lib', loader_pkg,
gtk_binary_version, 'loaders')
if os.path.isdir(loader_dist_dir):
shutil.rmtree(loader_dist_dir)
if os.path.isdir(loader_dir):
shutil.copytree(loader_dir, loader_dist_dir)
query_loaders = query_loaders.replace(gtk_dir,
'@executable_path/../Resources')
loaders_path = os.path.join(resources_dir, 'gdk-pixbuf.loaders')
with open(loaders_path, 'w') as loaders:
loaders.write(query_loaders)
if os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'immodules')):
shutil.rmtree(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'immodules'))
shutil.copytree(os.path.join(gtk_dir, 'lib', 'gtk-2.0',
gtk_binary_version, 'immodules'), os.path.join(gtk_2_dist_dir,
gtk_binary_version, 'immodules'))
query_immodules = Popen(os.path.join(gtk_dir, 'bin',
'gtk-query-immodules-2.0'), stdout=PIPE).stdout.read()
query_immodules = query_immodules.replace(gtk_dir,
'@executable_path/../Resources')
immodules_path = os.path.join(resources_dir, 'gtk.immodules')
with open(immodules_path, 'w') as immodules:
immodules.write(query_immodules)
with open(os.path.join(resources_dir, 'gtkrc'), 'w') as gtkrc:
for name, dirname in (
('Clearlooks', 'gtk-2.0'),
('Mac', 'gtk-2.0-key'),
):
rcfile = os.path.join(gtk_dir, 'share', 'themes', name,
dirname, 'gtkrc')
gtkrc.write(open(rcfile).read())
for lang in all_languages():
if os.path.isdir(os.path.join(resources_dir, 'share', 'locale',
lang)):
shutil.rmtree(os.path.join(resources_dir, 'share', 'locale',
lang))
if os.path.isdir(os.path.join(gtk_dir, 'share', 'locale', lang)):
shutil.copytree(os.path.join(gtk_dir, 'share', 'locale', lang),
os.path.join(resources_dir, 'share', 'locale', lang))
if os.path.isdir(os.path.join(os.path.dirname(__file__),
'share', 'locale', lang)):
shutil.copytree(os.path.join(os.path.dirname(__file__),
'share', 'locale', lang),
os.path.join(resources_dir, 'share', 'locale', lang))
# fix pathes within shared libraries
for library in chain(
iglob(os.path.join(loader_dist_dir, '*.so')),
iglob(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'engines', '*.so')),
iglob(os.path.join(gtk_2_dist_dir, gtk_binary_version,
'immodules', '*.so')),
iglob(os.path.join(pango_dist_dir, '*', 'modules', '*.so'))):
libs = [lib.split('(')[0].strip()
for lib in Popen(['otool', '-L', library],
stdout=PIPE).communicate()[0].splitlines()
if 'compatibility' in lib]
libs = dict(((lib, None) for lib in libs if gtk_dir in lib))
for lib in libs.keys():
fixed = lib.replace(gtk_dir + '/lib',
'@executable_path/../Frameworks')
Popen(['install_name_tool', '-change', lib, fixed,
library]).wait()
for file in ('CHANGELOG', 'COPYRIGHT', 'LICENSE', 'README', 'TODO'):
shutil.copyfile(os.path.join(os.path.dirname(__file__), file),
os.path.join(dist_dir, file + '.txt'))
doc_dist_dir = os.path.join(dist_dir, 'doc')
if os.path.isdir(doc_dist_dir):
shutil.rmtree(doc_dist_dir)
shutil.copytree(os.path.join(os.path.dirname(__file__), 'doc'),
doc_dist_dir)
dmg_file = os.path.join(os.path.dirname(__file__), 'tryton-' + VERSION
+ '.dmg')
if os.path.isfile(dmg_file):
os.remove(dmg_file)
Popen(['hdiutil', 'create', dmg_file, '-volname', 'Tryton Client '
+ VERSION, '-fs', 'HFS+', '-srcfolder', dist_dir]).wait()
|