2 # -*- coding: utf-8 -*-
3 ##############################################################################
5 # OpenERP, Open Source Management Solution
6 # Copyright (C) 2004-2010 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>
32 from os.path import join, isfile, basename
35 from distutils.core import setup, Command
36 from distutils.command.install import install
43 sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
45 execfile(join('bin', 'release.py'))
47 if sys.argv[1] == 'bdist_rpm':
48 version = version.split('-')[0]
50 # get python short version
51 py_short_version = '%s.%s' % sys.version_info[:2]
54 ('lxml', 'lxml module: pythonic libxml2 and libxslt bindings'),
55 ('mako', 'Mako template engine'),
56 ('dateutil', "Extensions to the standard datetime module"),
57 ('psycopg2', 'PostgreSQL module'),
58 ('pychart', 'pychart module'),
59 ('pydot', 'pydot module'),
60 ('pytz', 'Timezone handling library for Python'),
61 ('reportlab', 'reportlab module'),
62 ('yaml', 'YAML parser and emitter for Python'),
67 for modname, desc in required_modules:
69 imp.find_module(modname)
72 'Error: python module %s (%s) is required' % (modname, desc))
75 print '\n'.join(errors)
79 for root, _, names in os.walk(join('bin', 'addons')):
80 if '__openerp__.py' in names or '__terp__.py' in names:
81 yield basename(root), root
82 #look for extra modules
84 empath = os.getenv('EXTRA_MODULES_PATH', '../addons/')
85 for mname in open(join(empath, 'server_modules.list')):
90 terp = join(empath, mname, '__openerp__.py')
91 if not os.path.exists(terp):
92 terp = join(empath, mname, '__terp__.py')
94 if os.path.exists(terp):
95 yield mname, join(empath, mname)
97 print "Module %s specified, but no valid path." % mname
102 '''Build list of data files to be installed'''
105 for root, _, names in os.walk(join('bin','addons')):
106 files.append((root, [join(root, name) for name in names]))
107 for root, _, names in os.walk('doc'):
108 files.append((root, [join(root, name) for name in names]))
109 files.append(('.', [join('bin', 'import_xml.rng'),
110 join('bin', 'server.pkey'),
111 join('bin', 'server.cert')]))
113 man_directory = join('share', 'man')
114 files.append((join(man_directory, 'man1'), ['man/openerp-server.1']))
115 files.append((join(man_directory, 'man5'), ['man/openerp_serverrc.5']))
117 doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
118 files.append((doc_directory, filter(isfile, glob.glob('doc/*'))))
119 files.append((join(doc_directory, 'migrate', '3.3.0-3.4.0'),
120 filter(isfile, glob.glob('doc/migrate/3.3.0-3.4.0/*'))))
121 files.append((join(doc_directory, 'migrate', '3.4.0-4.0.0'),
122 filter(isfile, glob.glob('doc/migrate/3.4.0-4.0.0/*'))))
124 openerp_site_packages = join('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server')
126 files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
127 join('bin', 'server.pkey'),
128 join('bin', 'server.cert')]))
130 if sys.version_info[0:2] == (2,5):
131 files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
132 join('python25-compat','SimpleXMLRPCServer.py'),
133 join('python25-compat','SocketServer.py')]))
135 for addonname, add_path in find_addons():
136 addon_path = join('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server','addons', addonname)
137 for root, dirs, innerfiles in os.walk(add_path):
138 innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
140 res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
141 files.extend(((res, map(lambda fil: join(root, fil),
146 if not os.getenv('NO_CHECK_MODULES') :
149 f = file('openerp-server','w')
151 echo "Error: the content of this file should have been replaced during "
152 echo "installation\n"
157 def find_package_dirs():
158 package_dirs = {'openerp-server': 'bin'}
159 for mod, path in find_addons():
160 package_dirs['openerp-server.addons.' + mod] = path
163 class openerp_server_install(install):
165 # create startup script
166 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n"\
167 % (join(self.install_libbase, "openerp-server"), sys.executable)
169 f = open('openerp-server', 'w')
170 f.write(start_script)
179 "packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
180 "lxml.objectify", "decimal", "xml", "encodings",
181 "dateutil", "wizard", "pychart", "PIL", "pyparsing",
182 "pydot", "asyncore","asynchat", "reportlab", "vobject",
183 "HTMLParser", "select", "yaml"],
184 "excludes" : ["Tkconstants","Tkinter","tcl"],
190 description = description,
191 long_description = long_desc,
194 author_email = author_email,
195 classifiers = filter(None, classifiers.split("\n")),
197 data_files = data_files(),
199 'install' : openerp_server_install,
201 scripts = ['openerp-server'],
202 packages = ['openerp-server',
203 'openerp-server.addons',
205 'openerp-server.osv',
206 'openerp-server.pychart',
207 'openerp-server.pychart.afm',
208 'openerp-server.report',
209 'openerp-server.report.printscreen',
210 'openerp-server.report.pyPdf',
211 'openerp-server.report.render',
212 'openerp-server.report.render.html2html',
213 'openerp-server.report.render.makohtml2html',
214 'openerp-server.report.render.odt2odt',
215 'openerp-server.report.render.rml2html',
216 'openerp-server.report.render.rml2pdf',
217 'openerp-server.report.render.rml2txt',
218 'openerp-server.service',
219 'openerp-server.tools',
220 'openerp-server.wizard',
221 'openerp-server.workflow'] + \
222 [('openerp-server.addons.' + name)
223 for name, _ in find_addons()],
224 package_dir = find_package_dirs(),
225 console = [{"script": join("bin", "openerp-server.py"),
226 "icon_resources": [(1,join("pixmaps","openerp-icon.ico"))]
232 # Sometime between pytz-2008a and pytz-2008i common_timezones started to
233 # include only names of zones with a corresponding data file in zoneinfo.
234 # pytz installs the zoneinfo directory tree in the same directory
235 # as the pytz/__init__.py file. These data files are loaded using
236 # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
237 # resource_stream can't find the files and common_timezones is empty when
238 # read in the py2exe executable.
239 # This manually copies zoneinfo into the zip. See also
240 # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
243 # Make sure the layout of pytz hasn't changed
244 assert (pytz.__file__.endswith('__init__.pyc') or
245 pytz.__file__.endswith('__init__.py')), pytz.__file__
246 zoneinfo_dir = join(os.path.dirname(pytz.__file__), 'zoneinfo')
247 # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
248 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
249 zipfile_path = join(options['py2exe']['dist_dir'], 'library.zip')
250 z = zipfile.ZipFile(zipfile_path, 'a')
251 for absdir, directories, filenames in os.walk(zoneinfo_dir):
252 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
253 zip_dir = absdir[len(disk_basedir):]
255 z.write(join(absdir, f), join(zip_dir, f))