[FIX]:search_view 'groups=' attribute in the child of a field tag was never evaluted:
[odoo/odoo.git] / setup.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 ##############################################################################
4 #
5 #    OpenERP, Open Source Management Solution
6 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 #
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.
12 #
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.
17 #
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/>.
20 #
21 ##############################################################################
22
23 # setup from TinERP
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>
27 #
28
29 import imp
30 import sys
31 import os
32 from os.path import join, isfile, basename
33 import glob
34
35 from setuptools import setup, find_packages
36 from setuptools.command.install import install
37 from distutils.sysconfig import get_python_lib
38
39 has_py2exe = False
40 if os.name == 'nt':
41     import py2exe
42     has_py2exe = True
43
44 sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
45
46 execfile(join('bin', 'release.py'))
47
48 if 'bdist_rpm' in sys.argv:
49     version = version.split('-')[0]
50
51 # get python short version
52 py_short_version = '%s.%s' % sys.version_info[:2]
53
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
58
59     try:
60         names = listdir(top)
61     except error, err:
62         if onerror is not None:
63             onerror(err)
64         return
65
66     dirs, nondirs = [], []
67     for name in names:
68         if isdir(join(top, name)):
69             dirs.append(name)
70         else:
71             nondirs.append(name)
72
73     if topdown:
74         yield top, dirs, nondirs
75     for name in dirs:
76         path = join(top, name)
77         if followlinks or not islink(path):
78             for x in walk_followlinks(path, topdown, onerror, followlinks):
79                 yield x
80     if not topdown:
81         yield top, dirs, nondirs
82
83 if sys.version_info < (2, 6):
84     os.walk = walk_followlinks
85
86 def find_addons():
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
90
91 def data_files():
92     '''Build list of data files to be installed'''
93     files = []
94     if os.name == 'nt':
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')]))
104     else:
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']))
108
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/*'))))
115
116         openerp_site_packages = join(get_python_lib(prefix=''), 'openerp-server')
117
118         files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
119                                               join('bin', 'server.pkey'),
120                                               join('bin', 'server.cert')]))
121
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')]))
126
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)
131                 if innerfiles:
132                     res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
133                     files.extend(((res, map(lambda fil: join(root, fil),
134                                             innerfiles)),))
135
136     return files
137
138 f = file('openerp-server','w')
139 f.write("""#!/bin/sh
140 echo "Error: the content of this file should have been replaced during "
141 echo "installation\n"
142 exit 1
143 """)
144 f.close()
145
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
150     return package_dirs
151
152 class openerp_server_install(install):
153     def run(self):
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)
157         # write script
158         f = open('openerp-server', 'w')
159         f.write(start_script)
160         f.close()
161         install.run(self)
162
163
164
165 options = {
166     "py2exe": {
167         "compressed": 1,
168         "optimize": 2,
169         "dist_dir": 'dist',
170         "packages": [
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",
177                  ],
178         "excludes" : ["Tkconstants","Tkinter","tcl"],
179     }
180 }
181
182 setup(name             = name,
183       version          = version,
184       description      = description,
185       long_description = long_desc,
186       url              = url,
187       author           = author,
188       author_email     = author_email,
189       classifiers      = filter(None, classifiers.split("\n")),
190       license          = license,
191       data_files       = data_files(),
192       cmdclass         = {
193           'install' : openerp_server_install,
194       },
195       scripts          = ['openerp-server'],
196       packages = [
197           '.'.join(['openerp-server'] + package.split('.')[1:]) for package in find_packages()
198       ],
199       package_dir      = find_package_dirs(),
200       console = [
201           {
202               "script": join("bin", "openerp-server.py"),
203               "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))]
204           }
205       ],
206       options = options,
207       install_requires = ['lxml',
208                           'mako',
209                           'python-dateutil',
210                           'psycopg2',
211                           'pychart',
212                           'pydot',
213                           'pytz',
214                           'reportlab',
215                           'caldav',
216                           'pyyaml',
217                           'sqlalchemy',
218                           'django',
219                           'pywebdav'
220                           'cx_Oracle',
221                           'mysqldb',
222                           'feedparser',
223                           'bsddb3',
224                           'egenix-mx-base'],
225       extras_require={
226           'SSL' : ['pyopenssl'],
227       }
228 )
229
230 if has_py2exe:
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
240   import pytz
241   import zipfile
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):]
253     for f in filenames:
254       z.write(join(absdir, f), join(zip_dir, f))
255   z.close()
256