2 # -*- coding: utf-8 -*-
3 ##############################################################################
5 # OpenERP, Open Source Management Solution
6 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as
10 # published by the Free Software Foundation, either version 3 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 # taken from straw http://www.nongnu.org/straw/index.html
25 # taken from gnomolicious http://www.nongnu.org/gnomolicious/
26 # adapted by Nicolas Évrard <nicoe@altern.org>
34 from distutils.core import setup, Command
35 from distutils.command.install import install
42 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin"))
46 execfile(opj('bin', 'release.py'))
48 if sys.argv[1] == 'bdist_rpm':
49 version = version.split('-')[0]
51 # get python short version
52 py_short_version = '%s.%s' % sys.version_info[:2]
55 ('psycopg2', 'PostgreSQL module'),
56 ('xml', 'XML Tools for python'),
57 ('libxml2', 'libxml2 python bindings'),
58 ('libxslt', 'libxslt python bindings'),
59 ('reportlab', 'reportlab module'),
60 ('pychart', 'pychart module'),
61 ('pydot', 'pydot module'),
66 for modname, desc in required_modules:
68 exec('import %s' % modname)
71 print 'Error: python module %s (%s) is required' % (modname, desc)
77 for (dp, dn, names) in os.walk(opj('bin', 'addons')):
78 if '__terp__.py' in names:
79 modname = dp.replace(os.path.sep, '.').replace('bin', 'openerp-server', 1)
83 '''Build list of data files to be installed'''
87 for (dp,dn,names) in os.walk('addons'):
88 files.append((dp, map(lambda x: opj('bin', dp, x), names)))
90 for (dp,dn,names) in os.walk('doc'):
91 files.append((dp, map(lambda x: opj(dp, x), names)))
92 files.append(('.', [opj('bin', 'import_xml.rng'),
93 opj('bin', 'server.pkey'),
94 opj('bin', 'server.cert')]))
96 man_directory = opj('share', 'man')
97 files.append((opj(man_directory, 'man1'), ['man/openerp-server.1']))
98 files.append((opj(man_directory, 'man5'), ['man/openerp_serverrc.5']))
100 doc_directory = opj('share', 'doc', 'openerp-server-%s' % version)
101 files.append((doc_directory, [f for f in glob.glob('doc/*') if os.path.isfile(f)]))
102 files.append((opj(doc_directory, 'migrate', '3.3.0-3.4.0'), [f for f in glob.glob('doc/migrate/3.3.0-3.4.0/*') if os.path.isfile(f)]))
103 files.append((opj(doc_directory, 'migrate', '3.4.0-4.0.0'), [f for f in glob.glob('doc/migrate/3.4.0-4.0.0/*') if os.path.isfile(f)]))
105 openerp_site_packages = opj('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server')
107 files.append((openerp_site_packages, [opj('bin', 'import_xml.rng'),
108 opj('bin', 'server.pkey'),
109 opj('bin', 'server.cert')]))
111 for addon in find_addons():
112 addonname = addon.split('.')[-1]
113 add_path = addon.replace('.', os.path.sep).replace('openerp-server', 'bin', 1)
114 addon_path = opj('lib', 'python%s' % py_short_version, 'site-packages', add_path.replace('bin', 'openerp-server', 1))
116 for root, dirs, innerfiles in os.walk(add_path):
117 innerfiles = filter(lambda file: os.path.splitext(file)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
119 res = os.path.normpath(opj(addon_path, root.replace(opj('bin','addons', addonname), '.')))
120 pathfiles.extend(((res, map(lambda file: opj(root, file), innerfiles)),))
121 files.extend(pathfiles)
127 f = file('openerp-server','w')
128 start_script = """#!/bin/sh\necho "OpenERP Setup - The content of this file is generated at the install stage\n" """
129 f.write(start_script)
132 class openerp_server_install(install):
134 # create startup script
135 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n" % (opj(self.install_libbase, "openerp-server"), sys.executable)
137 f = open('openerp-server', 'w')
138 f.write(start_script)
147 "packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
148 "lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath",
149 "encodings","mx.DateTime","wizard","pychart","PIL", "pyparsing",
150 "pydot","asyncore","asynchat", "reportlab", "vobject",
151 "HTMLParser", "select"],
152 "excludes" : ["Tkconstants","Tkinter","tcl"],
158 description = description,
159 long_description = long_desc,
162 author_email = author_email,
163 classifiers = filter(None, classifiers.split("\n")),
165 data_files = data_files(),
167 'install' : openerp_server_install,
169 scripts = ['openerp-server'],
170 packages = ['openerp-server',
171 'openerp-server.addons',
173 'openerp-server.osv',
174 'openerp-server.service',
175 'openerp-server.tools',
176 'openerp-server.report',
177 'openerp-server.report.printscreen',
178 'openerp-server.report.pyPdf',
179 'openerp-server.report.render',
180 'openerp-server.report.render.rml2pdf',
181 'openerp-server.report.render.rml2html',
182 'openerp-server.wizard',
183 'openerp-server.report.render.odt2odt',
184 'openerp-server.report.render.html2html',
185 'openerp-server.workflow'] + \
187 package_dir = {'openerp-server': 'bin'},
188 console = [ { "script" : "bin\\openerp-server.py", "icon_resources" : [ (1,"pixmaps\\openerp-icon.ico") ] } ],
193 # Sometime between pytz-2008a and pytz-2008i common_timezones started to
194 # include only names of zones with a corresponding data file in zoneinfo.
195 # pytz installs the zoneinfo directory tree in the same directory
196 # as the pytz/__init__.py file. These data files are loaded using
197 # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
198 # resource_stream can't find the files and common_timezones is empty when
199 # read in the py2exe executable.
200 # This manually copies zoneinfo into the zip. See also
201 # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
204 # Make sure the layout of pytz hasn't changed
205 assert (pytz.__file__.endswith('__init__.pyc') or
206 pytz.__file__.endswith('__init__.py')), pytz.__file__
207 zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
208 # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
209 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
210 zipfile_path = os.path.join(options['py2exe']['dist_dir'], 'library.zip')
211 z = zipfile.ZipFile(zipfile_path, 'a')
212 for absdir, directories, filenames in os.walk(zoneinfo_dir):
213 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
214 zip_dir = absdir[len(disk_basedir):]
216 z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))