[ADD] openerp/netsvc: use cgitb to format the exception sent to the client, code...
[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 # doc/migrate is not included since about 6.1-dev
29 # doc/tests is not included
30 # python25-compat/*py should be in the openerp (and imported appropriately)
31
32 import sys
33 import os
34 from os.path import join, isfile
35 import glob
36
37 from setuptools import setup, find_packages
38
39 # Backports os.walk with followlinks from python 2.6.
40 # Needed to add all addons files to data_files for Windows packaging.
41 def walk_followlinks(top, topdown=True, onerror=None, followlinks=False):
42     from os.path import join, isdir, islink
43     from os import listdir, error
44
45     try:
46         names = listdir(top)
47     except error, err:
48         if onerror is not None:
49             onerror(err)
50         return
51
52     dirs, nondirs = [], []
53     for name in names:
54         if isdir(join(top, name)):
55             dirs.append(name)
56         else:
57             nondirs.append(name)
58
59     if topdown:
60         yield top, dirs, nondirs
61     for name in dirs:
62         path = join(top, name)
63         if followlinks or not islink(path):
64             for x in walk_followlinks(path, topdown, onerror, followlinks):
65                 yield x
66     if not topdown:
67         yield top, dirs, nondirs
68
69 if sys.version_info < (2, 6):
70     os.walk = walk_followlinks
71
72 py2exe_keywords = {}
73 py2exe_data_files = []
74 if os.name == 'nt':
75     import py2exe
76     py2exe_keywords['console'] = [
77         { "script": "openerp-server",
78           "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))],
79         }]
80     py2exe_keywords['options'] = {
81         "py2exe": {
82             "skip_archive": 1,
83             "optimize": 2,
84             "dist_dir": 'dist',
85             "packages": [
86                 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
87                 "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
88                 "encodings", "dateutil", "pychart", "PIL", "pyparsing",
89                 "pydot", "asyncore","asynchat", "reportlab", "vobject",
90                 "HTMLParser", "select", "mako", "poplib",
91                 "imaplib", "smtplib", "email", "yaml", "DAV",
92                 "uuid", "commands", "openerp", # TODO is it necessary to include cgitb?
93             ],
94             "excludes" : ["Tkconstants","Tkinter","tcl"],
95         }
96     }
97     # TODO is it still necessary now that we don't use the library.zip file?
98     def data_files():
99         '''For Windows, we consider all the addons as data files.
100            It seems also that package_data below isn't honored by py2exe.'''
101         files = []
102         os.chdir('openerp')
103         for (dp, dn, names) in os.walk('addons'):
104             files.append((join('openerp',dp), map(lambda x: join('openerp', dp, x), names)))
105         os.chdir('..')
106         files.append(('openerp', [join('openerp', 'import_xml.rng'),]))
107
108         # copy pytz/timzeone
109         # TODO check if we have to also copy dateutil's timezone data.
110         import pytz
111         # Make sure the layout of pytz hasn't changed
112         assert (pytz.__file__.endswith('__init__.pyc') or
113                 pytz.__file__.endswith('__init__.py')), pytz.__file__
114         pytz_dir = os.path.dirname(pytz.__file__)
115
116         saved_dir = os.getcwd()
117         os.chdir(pytz_dir)
118         for dp, dn, names in os.walk('zoneinfo'):
119             files.append((join('pytz',dp), map(lambda x: join(pytz_dir, dp, x), names)))
120         os.chdir(saved_dir)
121
122         return files
123     py2exe_data_files = data_files()
124
125 execfile(join('openerp', 'release.py'))
126
127 setup(name             = name,
128       version          = version,
129       description      = description,
130       long_description = long_desc,
131       url              = url,
132       author           = author,
133       author_email     = author_email,
134       classifiers      = filter(None, classifiers.split("\n")),
135       license          = license,
136       data_files       = [
137         (join('man', 'man1'), ['man/openerp-server.1']),
138         (join('man', 'man5'), ['man/openerp_serverrc.5']),
139         ('doc', filter(isfile, glob.glob('doc/*'))),
140       ] + py2exe_data_files,
141       scripts          = ['openerp-server'],
142       packages = find_packages(),
143       include_package_data = True,
144       package_data = {
145           '': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'],
146       },
147       dependency_links = ['http://download.gna.org/pychart/'],
148       install_requires = [
149        # We require the same version as caldav for lxml.
150           'lxml==2.1.5',
151           'mako',
152           'python-dateutil',
153           'psycopg2',
154         # TODO the pychart package we include in openerp corresponds to PyChart 1.37.
155         # It seems there is a single difference, which is a spurious print in generate_docs.py.
156         # It is probably safe to move to PyChart 1.39 (the latest one).
157         # (Let setup.py choose the latest one, and we should check we can remove pychart from
158         # our tree.)
159           'pychart',
160           'pydot',
161           'pytz',
162           'reportlab',
163           'caldav',
164           'pyyaml',
165           'pywebdav',
166           'feedparser',
167       ],
168       extras_require = {
169           'SSL' : ['pyopenssl'],
170       },
171       **py2exe_keywords
172 )
173