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>
31 from os.path import join, isfile, basename
34 from pprint import pprint as pp
36 from setuptools import setup, find_packages
37 from setuptools.command.install import install
38 from distutils.sysconfig import get_python_lib
45 py2exe_keywords['console'] = [
46 { "script": join("bin", "openerp-server.py"),
47 "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))]
49 py2exe_keywords['options'] = {
55 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
56 "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
57 "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing",
58 "pydot", "asyncore","asynchat", "reportlab", "vobject",
59 "HTMLParser", "select", "mako", "poplib",
60 "imaplib", "smtplib", "email", "yaml", "DAV",
63 "excludes" : ["Tkconstants","Tkinter","tcl"],
67 sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
69 execfile(join('bin', 'release.py'))
71 if 'bdist_rpm' in sys.argv:
72 version = version.split('-')[0]
74 # get python short version
75 py_short_version = '%s.%s' % sys.version_info[:2]
77 # backports os.walk with followlinks from python 2.6
78 def walk_followlinks(top, topdown=True, onerror=None, followlinks=False):
79 from os.path import join, isdir, islink
80 from os import listdir, error
85 if onerror is not None:
89 dirs, nondirs = [], []
91 if isdir(join(top, name)):
97 yield top, dirs, nondirs
99 path = join(top, name)
100 if followlinks or not islink(path):
101 for x in walk_followlinks(path, topdown, onerror, followlinks):
104 yield top, dirs, nondirs
106 if sys.version_info < (2, 6):
107 os.walk = walk_followlinks
110 for root, _, names in os.walk(join('bin', 'addons'), followlinks=True):
111 if '__openerp__.py' in names or '__terp__.py' in names:
112 yield basename(root), root
113 #look for extra modules
115 empath = os.getenv('EXTRA_MODULES_PATH', '../addons/')
116 for mname in open(join(empath, 'server_modules.list')):
117 mname = mname.strip()
121 terp = join(empath, mname, '__openerp__.py')
122 if not os.path.exists(terp):
123 terp = join(empath, mname, '__terp__.py')
125 if os.path.exists(terp):
126 yield mname, join(empath, mname)
128 print "Module %s specified, but no valid path." % mname
133 '''Build list of data files to be installed'''
137 for (dp, dn, names) in os.walk('addons'):
138 files.append((dp, map(lambda x: join('bin', dp, x), names)))
140 #for root, _, names in os.walk(join('bin','addons')):
141 # files.append((root, [join(root, name) for name in names]))
142 for root, _, names in os.walk('doc'):
143 files.append((root, [join(root, name) for name in names]))
144 #for root, _, names in os.walk('pixmaps'):
145 # files.append((root, [join(root, name) for name in names]))
146 files.append(('.', [join('bin', 'import_xml.rng'),]))
148 man_directory = join('share', 'man')
149 files.append((join(man_directory, 'man1'), ['man/openerp-server.1']))
150 files.append((join(man_directory, 'man5'), ['man/openerp_serverrc.5']))
152 doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
153 files.append((doc_directory, filter(isfile, glob.glob('doc/*'))))
154 files.append((join(doc_directory, 'migrate', '3.3.0-3.4.0'),
155 filter(isfile, glob.glob('doc/migrate/3.3.0-3.4.0/*'))))
156 files.append((join(doc_directory, 'migrate', '3.4.0-4.0.0'),
157 filter(isfile, glob.glob('doc/migrate/3.4.0-4.0.0/*'))))
159 openerp_site_packages = join(get_python_lib(prefix=''), 'openerp-server')
161 files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),]))
163 if sys.version_info[0:2] == (2,5):
164 files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
165 join('python25-compat','SimpleXMLRPCServer.py'),
166 join('python25-compat','SocketServer.py')]))
168 for addonname, add_path in find_addons():
169 addon_path = join(get_python_lib(prefix=''), 'openerp-server','addons', addonname)
170 for root, dirs, innerfiles in os.walk(add_path):
171 innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
173 res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
174 files.extend(((res, map(lambda fil: join(root, fil),
179 f = file('openerp-server','w')
181 echo "Error: the content of this file should have been replaced during "
182 echo "installation\n"
187 def find_package_dirs():
188 package_dirs = {'openerp-server': 'bin'}
189 for mod, path in find_addons():
190 package_dirs['openerp-server.addons.' + mod] = path
193 class openerp_server_install(install):
195 # create startup script
196 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n"\
197 % (join(self.install_libbase, "openerp-server"), sys.executable)
199 f = open('openerp-server', 'w')
200 f.write(start_script)
209 description = description,
210 long_description = long_desc,
213 author_email = author_email,
214 classifiers = filter(None, classifiers.split("\n")),
216 data_files = data_files(),
218 'install' : openerp_server_install,
220 scripts = ['openerp-server'],
222 '.'.join(['openerp-server'] + package.split('.')[1:])
223 for package in find_packages()
225 include_package_data = True,
227 '': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'],
229 package_dir = find_package_dirs(),
245 'SSL' : ['pyopenssl'],
251 # Sometime between pytz-2008a and pytz-2008i common_timezones started to
252 # include only names of zones with a corresponding data file in zoneinfo.
253 # pytz installs the zoneinfo directory tree in the same directory
254 # as the pytz/__init__.py file. These data files are loaded using
255 # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
256 # resource_stream can't find the files and common_timezones is empty when
257 # read in the py2exe executable.
258 # This manually copies zoneinfo into the zip. See also
259 # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
262 # Make sure the layout of pytz hasn't changed
263 assert (pytz.__file__.endswith('__init__.pyc') or
264 pytz.__file__.endswith('__init__.py')), pytz.__file__
265 zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
266 # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
267 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
268 zipfile_path = os.path.join(py2exe_keywords['options']['py2exe']['dist_dir'], 'library.zip')
269 z = zipfile.ZipFile(zipfile_path, 'a')
271 for absdir, directories, filenames in os.walk(zoneinfo_dir):
272 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
273 zip_dir = absdir[len(disk_basedir):]
275 z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))