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 setuptools import setup, find_packages
36 from setuptools.command.install import install
37 from distutils.sysconfig import get_python_lib
44 sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
46 execfile(join('bin', 'release.py'))
48 if 'bdist_rpm' in sys.argv:
49 version = version.split('-')[0]
51 # get python short version
52 py_short_version = '%s.%s' % sys.version_info[:2]
55 for root, _, names in os.walk(join('bin', 'addons'), followlinks=True):
56 if '__openerp__.py' in names or '__terp__.py' in names:
57 yield basename(root), root
60 '''Build list of data files to be installed'''
63 for root, _, names in os.walk(join('bin','addons')):
64 files.append((root, [join(root, name) for name in names]))
65 for root, _, names in os.walk('doc'):
66 files.append((root, [join(root, name) for name in names]))
67 files.append(('.', [join('bin', 'import_xml.rng'),
68 join('bin', 'server.pkey'),
69 join('bin', 'server.cert')]))
71 man_directory = join('share', 'man')
72 files.append((join(man_directory, 'man1'), ['man/openerp-server.1']))
73 files.append((join(man_directory, 'man5'), ['man/openerp_serverrc.5']))
75 doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
76 files.append((doc_directory, filter(isfile, glob.glob('doc/*'))))
77 files.append((join(doc_directory, 'migrate', '3.3.0-3.4.0'),
78 filter(isfile, glob.glob('doc/migrate/3.3.0-3.4.0/*'))))
79 files.append((join(doc_directory, 'migrate', '3.4.0-4.0.0'),
80 filter(isfile, glob.glob('doc/migrate/3.4.0-4.0.0/*'))))
82 openerp_site_packages = join(get_python_lib(prefix=''), 'openerp-server')
84 files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
85 join('bin', 'server.pkey'),
86 join('bin', 'server.cert')]))
88 if sys.version_info[0:2] == (2,5):
89 files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
90 join('python25-compat','SimpleXMLRPCServer.py'),
91 join('python25-compat','SocketServer.py')]))
93 for addonname, add_path in find_addons():
94 addon_path = join(get_python_lib(prefix=''), 'openerp-server','addons', addonname)
95 for root, dirs, innerfiles in os.walk(add_path):
96 innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
98 res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
99 files.extend(((res, map(lambda fil: join(root, fil),
104 f = file('openerp-server','w')
106 echo "Error: the content of this file should have been replaced during "
107 echo "installation\n"
112 def find_package_dirs():
113 package_dirs = {'openerp-server': 'bin'}
114 for mod, path in find_addons():
115 package_dirs['openerp-server.addons.' + mod] = path
118 class openerp_server_install(install):
120 # create startup script
121 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n"\
122 % (join(self.install_libbase, "openerp-server"), sys.executable)
124 f = open('openerp-server', 'w')
125 f.write(start_script)
137 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
138 "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
139 "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing",
140 "pydot", "asyncore","asynchat", "reportlab", "vobject",
141 "HTMLParser", "select", "mako", "poplib",
142 "imaplib", "smtplib", "email", "yaml","pywebdav",
144 "excludes" : ["Tkconstants","Tkinter","tcl"],
150 description = description,
151 long_description = long_desc,
154 author_email = author_email,
155 classifiers = filter(None, classifiers.split("\n")),
157 data_files = data_files(),
159 'install' : openerp_server_install,
161 scripts = ['openerp-server'],
163 '.'.join(['openerp-server'] + package.split('.')[1:]) for package in find_packages()
165 package_dir = find_package_dirs(),
168 "script": join("bin", "openerp-server.py"),
169 "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))]
173 install_requires = ['lxml',
192 'SSL' : ['pyopenssl'],
197 # Sometime between pytz-2008a and pytz-2008i common_timezones started to
198 # include only names of zones with a corresponding data file in zoneinfo.
199 # pytz installs the zoneinfo directory tree in the same directory
200 # as the pytz/__init__.py file. These data files are loaded using
201 # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
202 # resource_stream can't find the files and common_timezones is empty when
203 # read in the py2exe executable.
204 # This manually copies zoneinfo into the zip. See also
205 # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
208 # Make sure the layout of pytz hasn't changed
209 assert (pytz.__file__.endswith('__init__.pyc') or
210 pytz.__file__.endswith('__init__.py')), pytz.__file__
211 zoneinfo_dir = join(os.path.dirname(pytz.__file__), 'zoneinfo')
212 # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
213 disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
214 zipfile_path = join(options['py2exe']['dist_dir'], 'library.zip')
215 z = zipfile.ZipFile(zipfile_path, 'a')
216 for absdir, directories, filenames in os.walk(zoneinfo_dir):
217 assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
218 zip_dir = absdir[len(disk_basedir):]
220 z.write(join(absdir, f), join(zip_dir, f))