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]
54 # backports os.walk with followlinks from python 2.6
55 def walk_followlinks(top, topdown=True, onerror=None, followlinks=False):
56 from os.path import join, isdir, islink
57 from os import listdir, error
62 if onerror is not None:
66 dirs, nondirs = [], []
68 if isdir(join(top, name)):
74 yield top, dirs, nondirs
76 path = join(top, name)
77 if followlinks or not islink(path):
78 for x in walk_followlinks(path, topdown, onerror, followlinks):
81 yield top, dirs, nondirs
83 if sys.version_info < (2, 6):
84 os.walk = walk_followlinks
87 for root, _, names in os.walk(join('bin', 'addons'), followlinks=True):
88 if '__openerp__.py' in names or '__terp__.py' in names:
89 yield basename(root), root
92 '''Build list of data files to be installed'''
95 for root, _, names in os.walk(join('bin','addons')):
96 files.append((root, [join(root, name) for name in names]))
97 for root, _, names in os.walk('doc'):
98 files.append((root, [join(root, name) for name in names]))
99 for root, _, names in os.walk('pixmaps'):
100 files.append((root, [join(root, name) for name in names]))
101 files.append(('.', [join('bin', 'import_xml.rng'),
102 join('bin', 'server.pkey'),
103 join('bin', 'server.cert')]))
105 man_directory = join('share', 'man')
106 files.append((join(man_directory, 'man1'), ['man/openerp-server.1']))
107 files.append((join(man_directory, 'man5'), ['man/openerp_serverrc.5']))
109 doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
110 files.append((doc_directory, filter(isfile, glob.glob('doc/*'))))
111 files.append((join(doc_directory, 'migrate', '3.3.0-3.4.0'),
112 filter(isfile, glob.glob('doc/migrate/3.3.0-3.4.0/*'))))
113 files.append((join(doc_directory, 'migrate', '3.4.0-4.0.0'),
114 filter(isfile, glob.glob('doc/migrate/3.4.0-4.0.0/*'))))
116 openerp_site_packages = join(get_python_lib(prefix=''), 'openerp-server')
118 files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
119 join('bin', 'server.pkey'),
120 join('bin', 'server.cert')]))
122 if sys.version_info[0:2] == (2,5):
123 files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
124 join('python25-compat','SimpleXMLRPCServer.py'),
125 join('python25-compat','SocketServer.py')]))
127 for addonname, add_path in find_addons():
128 addon_path = join(get_python_lib(prefix=''), 'openerp-server','addons', addonname)
129 for root, dirs, innerfiles in os.walk(add_path):
130 innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
132 res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
133 files.extend(((res, map(lambda fil: join(root, fil),
138 f = file('openerp-server','w')
140 echo "Error: the content of this file should have been replaced during "
141 echo "installation\n"
146 def find_package_dirs():
147 package_dirs = {'openerp-server': 'bin'}
148 for mod, path in find_addons():
149 package_dirs['openerp-server.addons.' + mod] = path
152 class openerp_server_install(install):
154 # create startup script
155 start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n"\
156 % (join(self.install_libbase, "openerp-server"), sys.executable)
158 f = open('openerp-server', 'w')
159 f.write(start_script)
171 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
172 "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
173 "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing",
174 "pydot", "asyncore","asynchat", "reportlab", "vobject",
175 "HTMLParser", "select", "mako", "poplib",
176 "imaplib", "smtplib", "email", "yaml", "DAV",
178 "excludes" : ["Tkconstants","Tkinter","tcl"],
184 description = description,
185 long_description = long_desc,
188 author_email = author_email,
189 classifiers = filter(None, classifiers.split("\n")),
191 data_files = data_files(),
193 'install' : openerp_server_install,
195 scripts = ['openerp-server'],
197 '.'.join(['openerp-server'] + package.split('.')[1:]) for package in find_packages()
199 package_dir = find_package_dirs(),
202 "script": join("bin", "openerp-server.py"),
203 "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))]
207 install_requires = ['lxml',
226 'SSL' : ['pyopenssl'],
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 = 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 = 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(join(absdir, f), join(zip_dir, f))