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