[FIX] setup.py: py2exe, sdist, and install seem good.
[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.py",
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",
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         return files
108     py2exe_data_files = data_files()
109
110 execfile(join('openerp', 'release.py'))
111
112 setup(name             = name,
113       version          = version,
114       description      = description,
115       long_description = long_desc,
116       url              = url,
117       author           = author,
118       author_email     = author_email,
119       classifiers      = filter(None, classifiers.split("\n")),
120       license          = license,
121       data_files       = [
122         (join('man', 'man1'), ['man/openerp-server.1']),
123         (join('man', 'man5'), ['man/openerp_serverrc.5']),
124         ('doc', filter(isfile, glob.glob('doc/*'))),
125       ] + py2exe_data_files,
126       scripts          = ['openerp-server.py'],
127       packages = find_packages(),
128       include_package_data = True,
129       package_data = {
130           '': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'],
131       },
132       dependency_links = ['http://download.gna.org/pychart/'],
133       install_requires = [
134        # We require the same version as caldav for lxml.
135           'lxml==2.1.5',
136           'mako',
137           'python-dateutil',
138           'psycopg2',
139         # TODO the pychart package we include in openerp corresponds to PyChart 1.37.
140         # It seems there is a single difference, which is a spurious print in generate_docs.py.
141         # It is probably safe to move to PyChart 1.39 (the latest one).
142         # (Let setup.py choose the latest one, and we should check we can remove pychart from
143         # our tree.)
144           'pychart',
145           'pydot',
146           'pytz',
147           'reportlab',
148           'caldav',
149           'pyyaml',
150           'pywebdav',
151           'feedparser',
152       ],
153       extras_require = {
154           'SSL' : ['pyopenssl'],
155       },
156       **py2exe_keywords
157 )
158