bugfixed for menu disable
[openerp-client.git] / setup.py
blob99b4e1deeebfc934ddb500dc75c8b781a7162263
1 # -*- coding: utf-8 -*-
2 #!/usr/bin/env python
3 # -*- encoding: utf-8 -*-
4 ##############################################################################
6 # Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
8 # $Id$
10 # WARNING: This program as such is intended to be used by professional
11 # programmers who take the whole responsability of assessing all potential
12 # consequences resulting from its eventual inadequacies and bugs
13 # End users who are looking for a ready-to-use solution with commercial
14 # garantees and support are strongly adviced to contract a Free Software
15 # Service Company
17 # This program is Free Software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 ###############################################################################
31 # setup from TinERP
32 # taken from straw http://www.nongnu.org/straw/index.html
33 # taken from gnomolicious http://www.nongnu.org/gnomolicious/
34 # adapted by Nicolas Évrard <nicoe@altern.org>
36 import imp
37 import sys
38 import os
39 import glob
41 from stat import ST_MODE
43 from distutils.file_util import copy_file
44 from distutils.core import setup
45 from mydistutils import L10nAppDistribution
47 if os.name == 'nt':
48 import py2exe
50 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin"))
52 opj = os.path.join
54 execfile(opj('bin', 'release.py'))
57 # get python short version
58 py_short_version = '%s.%s' % sys.version_info[:2]
60 required_modules = [('gtk', 'gtk python bindings'),
61 ('gtk.glade', 'glade python bindings'),
62 ('mx.DateTime', 'date and time handling routines for Python')]
64 def check_modules():
65 ok = True
66 for modname, desc in required_modules:
67 try:
68 exec('import %s' % modname)
69 except ImportError:
70 ok = False
71 print 'Error: python module %s (%s) is required' % (modname, desc)
73 if not ok:
74 sys.exit(1)
76 def data_files():
77 '''Build list of data files to be installed'''
78 files = []
79 if os.name == 'nt':
80 import matplotlib
81 datafiles = matplotlib.get_py2exe_datafiles()
82 if isinstance(datafiles, list):
83 files.extend(datafiles)
84 else:
85 files.append(datafiles)
86 os.chdir('bin')
87 for (dp,dn,names) in os.walk('themes'):
88 if '.svn' in dn:
89 dn.remove('.svn')
90 files.append((dp, map(lambda x: opj('bin', dp,x), names)))
91 for (dp, dn, names) in os.walk('share\\locale'):
92 if '.svn' in dn:
93 dn.remove('.svn')
94 files.append((dp, map(lambda x: opj('bin', dp, x), names)))
95 os.chdir('..')
96 files.append((".",["bin\\terp.glade", 'bin\\tipoftheday.txt', 'doc\\README.txt']))
97 files.append(("pixmaps", glob.glob("bin\\pixmaps\\*.*")))
98 files.append(("po", glob.glob("bin\\po\\*.*")))
99 files.append(("icons", glob.glob("bin\\icons\\*.png")))
100 files.append(("share\\locale", glob.glob("bin\\share\\locale\\*.*")))
101 else:
102 files.append((opj('share','man','man1',''),['man/openerp-client.1']))
103 files.append((opj('share','doc', 'openerp-client-%s' % version), [f for
104 f in glob.glob('doc/*') if os.path.isfile(f)]))
105 files.append((opj('share', 'pixmaps', 'openerp-client'),
106 glob.glob('bin/pixmaps/*.png')))
107 files.append((opj('share', 'pixmaps', 'openerp-client', 'icons'),
108 glob.glob('bin/icons/*.png')))
109 files.append((opj('share', 'openerp-client'), ['bin/terp.glade',
110 'bin/tipoftheday.txt']))
111 return files
113 included_plugins = ['workflow_print']
115 def find_plugins():
116 for plugin in included_plugins:
117 path=opj('bin', 'plugins', plugin)
118 for dirpath, dirnames, filenames in os.walk(path):
119 if '__init__.py' in filenames:
120 modname = dirpath.replace(os.path.sep, '.')
121 yield modname.replace('bin', 'openerp-client', 1)
123 def translations():
124 trans = []
125 dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
126 for po in glob.glob('bin/po/*.po'):
127 lang = os.path.splitext(os.path.basename(po))[0]
128 trans.append((dest % (lang, name), po))
129 return trans
131 check_modules()
133 # create startup script
134 start_script = \
135 "#!/bin/sh\n\
136 cd %s/lib/python%s/site-packages/openerp-client\n\
137 exec %s ./openerp-client.py $@" % (sys.prefix, py_short_version, sys.executable)
138 # write script
139 f = open('openerp-client', 'w')
140 f.write(start_script)
141 f.close()
143 if os.name <> 'nt' and sys.argv[1] == 'build_po':
144 os.system('(cd bin ; find . -name \*.py && find . -name \*.glade | xargs xgettext -o po/%s.pot)' % name)
145 for file in ([ os.path.join('bin', 'po', fname) for fname in os.listdir('bin/po') ]):
146 if os.path.isfile(file):
147 os.system('msgmerge --update --backup=off %s bin/po/%s.pot' % (file, name))
148 sys.exit()
150 options = {"py2exe": {"compressed": 1,
151 "optimize": 2,
152 "packages": ["encodings","gtk", "matplotlib", "pytz"],
153 "includes": "pango,atk,gobject,cairo,atk,pangocairo",
154 "excludes": ["Tkinter", "tcl", "TKconstants"],
155 "dll_excludes": [
156 "iconv.dll","intl.dll","libatk-1.0-0.dll",
157 "libgdk_pixbuf-2.0-0.dll","libgdk-win32-2.0-0.dll",
158 "libglib-2.0-0.dll","libgmodule-2.0-0.dll",
159 "libgobject-2.0-0.dll","libgthread-2.0-0.dll",
160 "libgtk-win32-2.0-0.dll","libpango-1.0-0.dll",
161 "libpangowin32-1.0-0.dll",
162 "wxmsw26uh_vc.dll",],
166 setup(name = name,
167 version = version,
168 description = description,
169 long_description = long_desc,
170 url = url,
171 author = author,
172 author_email = author_email,
173 classifiers = filter(None, classifiers.splitlines()),
174 license = license,
175 data_files = data_files(),
176 translations = translations(),
177 scripts = ['openerp-client'],
178 packages = ['openerp-client', 'openerp-client.common',
179 'openerp-client.modules', 'openerp-client.modules.action',
180 'openerp-client.modules.gui',
181 'openerp-client.modules.gui.window',
182 'openerp-client.modules.gui.window.view_sel',
183 'openerp-client.modules.gui.window.view_tree',
184 'openerp-client.modules.spool',
185 'openerp-client.printer', 'openerp-client.tools',
186 'openerp-client.tinygraph',
187 'openerp-client.widget',
188 'openerp-client.widget.model',
189 'openerp-client.widget.screen',
190 'openerp-client.widget.view',
191 'openerp-client.widget.view.form_gtk',
192 'openerp-client.widget.view.tree_gtk',
193 'openerp-client.widget.view.graph_gtk',
194 'openerp-client.widget.view.calendar_gtk',
195 'openerp-client.widget_search',
196 'openerp-client.plugins'] + list(find_plugins()),
197 package_dir = {'openerp-client': 'bin'},
198 distclass = os.name <> 'nt' and L10nAppDistribution or None,
199 windows=[{"script":"bin\\openerp-client.py", "icon_resources":[(1,"bin\\pixmaps\\openerp.ico")]}],
200 options = options,
205 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: