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 = os.path.basename(dp)
81 #look for extra modules
83 empath = os.getenv('EXTRA_MODULES_PATH','../addons/')
84 f = open(opj(empath,'server_modules.list'),'r')
85 # print 'Getting modules from:' , opj(empath,'server_modules.list')
91 if os.path.exists(opj(empath,mname,'__terp__.py')):
92 yield ( mname, opj(empath,mname) )
94 print "Module %s specified, but no valid path." % mname
100 # Cache the results of _find_addons() and return them
101 def find_addons(found_addons = None):
103 found_addons = _find_addons()
107 '''Build list of data files to be installed'''
111 for (dp,dn,names) in os.walk('addons'):
112 files.append((dp, map(lambda x: opj('bin', dp, x), names)))
114 for (dp,dn,names) in os.walk('doc'):
115 files.append((dp, map(lambda x: opj(dp, x), names)))
116 files.append(('.', [opj('bin', 'import_xml.rng'),
117 opj('bin', 'server.pkey'),
118 opj('bin', 'server.cert')]))
120 man_directory = opj('share', 'man')
121 files.append((opj(man_directory, 'man1'), ['man/openerp-server.1']))
122 files.append((opj(man_directory, 'man5'), ['man/openerp_serverrc.5']))
124 doc_directory = opj('share', 'doc', 'openerp-server-%s' % version)
125 files.append((doc_directory, [f for f in glob.glob('doc/*') if os.path.isfile(f)]))
126 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)]))
127 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)]))
129 openerp_site_packages = opj('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server')
131 files.append((openerp_site_packages, [opj('bin', 'import_xml.rng'),
132 opj('bin', 'server.pkey'),
133 opj('bin', 'server.cert')]))
135 if sys.version_info[0:2] == (2,5):
136 files.append((openerp_site_packages, [ opj('python25-compat','BaseHTTPServer.py'),
137 opj('python25-compat','SimpleXMLRPCServer.py'),
138 opj('python25-compat','SocketServer.py')]))
140 for (addonname, add_path) in find_addons():
141 addon_path = opj('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server','addons', addonname)
143 for root, dirs, innerfiles in os.walk(add_path):
144 innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
146 res = os.path.normpath(opj(addon_path, root.replace(opj(add_path), '.')))
147 pathfiles.extend(((res, map(lambda fil: opj(root, fil), innerfiles)),))
148 files.extend(pathfiles)
151 # print "Files:", tup[0], tup[1]
154 if not os.getenv('NO_CHECK_MODULES',False) :
157 f = file('openerp-server','w')
158 start_script = """#!/bin/sh\necho "OpenERP Setup - The content of this file is generated at the install stage\n" """
159 f.write(start_script)
162 def find_package_dirs():
164 for (mod, path) in find_addons():
165 res ['openerp-server.addons.'+ mod ] = path
166 res ['openerp-server'] = 'bin'
169 class openerp_server_install(install):
171 # create startup script
172 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n" % (opj(self.install_libbase, "openerp-server"), sys.executable)
174 f = open('openerp-server', 'w')
175 f.write(start_script)
184 "packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
185 "lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath",
186 "encodings","mx.DateTime","wizard","pychart","PIL", "pyparsing",
187 "pydot","asyncore","asynchat", "reportlab", "vobject",
188 "HTMLParser", "select"],
189 "excludes" : ["Tkconstants","Tkinter","tcl"],
195 description = description,
196 long_description = long_desc,
199 author_email = author_email,
200 classifiers = filter(None, classifiers.split("\n")),
202 data_files = data_files(),
204 'install' : openerp_server_install,
206 scripts = ['openerp-server'],
207 packages = ['openerp-server',
208 'openerp-server.addons',
210 'openerp-server.osv',
211 'openerp-server.service',
212 'openerp-server.tools',
213 'openerp-server.report',
214 'openerp-server.report.printscreen',
215 'openerp-server.report.pyPdf',
216 'openerp-server.report.render',
217 'openerp-server.report.render.rml2pdf',
218 'openerp-server.report.render.rml2html',
219 'openerp-server.report.render.rml2txt',
220 'openerp-server.report.render.html2html',
221 'openerp-server.wizard',
222 'openerp-server.report.render.odt2odt',
223 'openerp-server.workflow'] + \
224 list(map( lambda (a, p): 'openerp-server.addons.'+ a ,find_addons())),
225 package_dir = find_package_dirs(),
226 console = [ { "script" : "bin\\openerp-server.py", "icon_resources" : [ (1,"pixmaps\\openerp-icon.ico") ] } ],
231 # Sometime between pytz-2008a and pytz-2008i common_timezones started to
232 # include only names of zones with a corresponding data file in zoneinfo.
233 # pytz installs the zoneinfo directory tree in the same directory
234 # as the pytz/__init__.py file. These data files are loaded using
235 # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
236 # resource_stream can't find the files and common_timezones is empty when
237 # read in the py2exe executable.
238 # This manually copies zoneinfo into the zip. See also
239 # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
242 # Make sure the layout of pytz hasn't changed
243 assert (pytz.__file__.endswith('__init__.pyc') or
244 pytz.__file__.endswith('__init__.py')), pytz.__file__
245 zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
246 # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
247 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
248 zipfile_path = os.path.join(options['py2exe']['dist_dir'], 'library.zip')
249 z = zipfile.ZipFile(zipfile_path, 'a')
250 for absdir, directories, filenames in os.walk(zoneinfo_dir):
251 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
252 zip_dir = absdir[len(disk_basedir):]
254 z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))