graph generation: get the label associated to selection instead of its value
[openerp-client.git] / setup.py
blob4f6d897cb3824b9239890c1a1ea0744890cafafd
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # setup from TinERP
4 # taken from straw http://www.nongnu.org/straw/index.html
5 # taken from gnomolicious http://www.nongnu.org/gnomolicious/
6 # adapted by Nicolas Évrard <nicoe@altern.org>
8 import imp
9 import sys
10 import os
11 import glob
13 from stat import ST_MODE
15 from distutils.file_util import copy_file
16 from distutils.core import setup
17 from mydistutils import L10nAppDistribution
19 if os.name == 'nt':
20 import py2exe
22 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin"))
24 opj = os.path.join
26 execfile(opj('bin', 'release.py'))
29 # get python short version
30 py_short_version = '%s.%s' % sys.version_info[:2]
32 required_modules = [('gtk', 'gtk python bindings'),
33 ('gtk.glade', 'glade python bindings'),
34 ('mx.DateTime', 'date and time handling routines for Python')]
36 def check_modules():
37 ok = True
38 for modname, desc in required_modules:
39 try:
40 exec('import %s' % modname)
41 except ImportError:
42 ok = False
43 print 'Error: python module %s (%s) is required' % (modname, desc)
45 if not ok:
46 sys.exit(1)
48 def data_files():
49 '''Build list of data files to be installed'''
50 files = []
51 if os.name == 'nt':
52 import matplotlib
53 datafiles = matplotlib.get_py2exe_datafiles()
54 if isinstance(datafiles, list):
55 files.extend(datafiles)
56 else:
57 files.append(datafiles)
58 os.chdir('bin')
59 for (dp,dn,names) in os.walk('themes'):
60 if '.svn' in dn:
61 dn.remove('.svn')
62 files.append((dp, map(lambda x: opj('bin', dp,x), names)))
63 for (dp, dn, names) in os.walk('share\\locale'):
64 if '.svn' in dn:
65 dn.remove('.svn')
66 files.append((dp, map(lambda x: opj('bin', dp, x), names)))
67 os.chdir('..')
68 files.append((".",["bin\\terp.glade", 'bin\\tipoftheday.txt', 'doc\\README.txt']))
69 files.append(("pixmaps", glob.glob("bin\\pixmaps\\*.*")))
70 files.append(("po", glob.glob("bin\\po\\*.*")))
71 files.append(("icons", glob.glob("bin\\icons\\*.png")))
72 files.append(("share\\locale", glob.glob("bin\\share\\locale\\*.*")))
73 else:
74 files.append((opj('share','man','man1',''),['man/tinyerp-client.1']))
75 files.append((opj('share','doc', 'tinyerp-client-%s' % version), [f for
76 f in glob.glob('doc/*') if os.path.isfile(f)]))
77 files.append((opj('share', 'pixmaps', 'tinyerp-client'),
78 glob.glob('bin/pixmaps/*.png')))
79 files.append((opj('share', 'pixmaps', 'tinyerp-client', 'icons'),
80 glob.glob('bin/icons/*.png')))
81 files.append((opj('share', 'tinyerp-client'), ['bin/terp.glade',
82 'bin/tipoftheday.txt']))
83 return files
85 included_plugins = ['workflow_print']
87 def find_plugins():
88 for plugin in included_plugins:
89 path=opj('bin', 'plugins', plugin)
90 for dirpath, dirnames, filenames in os.walk(path):
91 if '__init__.py' in filenames:
92 modname = dirpath.replace(os.path.sep, '.')
93 yield modname.replace('bin', 'tinyerp-client', 1)
95 def translations():
96 trans = []
97 dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
98 for po in glob.glob('bin/po/*.po'):
99 lang = os.path.splitext(os.path.basename(po))[0]
100 trans.append((dest % (lang, name), po))
101 return trans
103 check_modules()
105 # create startup script
106 start_script = \
107 "#!/bin/sh\n\
108 cd %s/lib/python%s/site-packages/tinyerp-client\n\
109 exec %s ./tinyerp-client.py $@" % (sys.prefix, py_short_version, sys.executable)
110 # write script
111 f = open('tinyerp-client', 'w')
112 f.write(start_script)
113 f.close()
115 if os.name <> 'nt' and sys.argv[1] == 'build_po':
116 os.system('(cd bin ; find . -name \*.py && find . -name \*.glade | xargs xgettext -o po/%s.pot)' % name)
117 for file in ([ os.path.join('bin', 'po', fname) for fname in os.listdir('bin/po') ]):
118 if os.path.isfile(file):
119 os.system('msgmerge --update --backup=off %s bin/po/%s.pot' % (file, name))
120 sys.exit()
122 options = {"py2exe": {"compressed": 1,
123 "optimize": 2,
124 "packages": ["encodings","gtk", "matplotlib", "pytz"],
125 "includes": "pango,atk,gobject,cairo,atk,pangocairo",
126 "excludes": ["Tkinter", "tcl", "TKconstants"],
127 "dll_excludes": [
128 "iconv.dll","intl.dll","libatk-1.0-0.dll",
129 "libgdk_pixbuf-2.0-0.dll","libgdk-win32-2.0-0.dll",
130 "libglib-2.0-0.dll","libgmodule-2.0-0.dll",
131 "libgobject-2.0-0.dll","libgthread-2.0-0.dll",
132 "libgtk-win32-2.0-0.dll","libpango-1.0-0.dll",
133 "libpangowin32-1.0-0.dll",
134 "wxmsw26uh_vc.dll",],
138 setup(name = name,
139 version = version,
140 description = description,
141 long_description = long_desc,
142 url = url,
143 author = author,
144 author_email = author_email,
145 classifiers = filter(None, classifiers.splitlines()),
146 license = license,
147 data_files = data_files(),
148 translations = translations(),
149 scripts = ['tinyerp-client'],
150 packages = ['tinyerp-client', 'tinyerp-client.common',
151 'tinyerp-client.modules', 'tinyerp-client.modules.action',
152 'tinyerp-client.modules.gui',
153 'tinyerp-client.modules.gui.window',
154 'tinyerp-client.modules.gui.window.view_sel',
155 'tinyerp-client.modules.gui.window.view_tree',
156 'tinyerp-client.modules.spool',
157 'tinyerp-client.printer', 'tinyerp-client.tools',
158 'tinyerp-client.tinygraph',
159 'tinyerp-client.widget',
160 'tinyerp-client.widget.model',
161 'tinyerp-client.widget.screen',
162 'tinyerp-client.widget.view',
163 'tinyerp-client.widget.view.form_gtk',
164 'tinyerp-client.widget.view.tree_gtk',
165 'tinyerp-client.widget.view.graph_gtk',
166 'tinyerp-client.widget.view.calendar_gtk',
167 'tinyerp-client.widget_search',
168 'tinyerp-client.plugins'] + list(find_plugins()),
169 package_dir = {'tinyerp-client': 'bin'},
170 distclass = os.name <> 'nt' and L10nAppDistribution or None,
171 windows=[{"script":"bin\\tinyerp-client.py", "icon_resources":[(1,"bin\\pixmaps\\tinyerp.ico")]}],
172 options = options,
176 # vim:expandtab:tw=80