[FIX] setup.py (windows): add some babel files not automatically included by py2exe.
[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 import glob, os, re, setuptools, sys
24 from os.path import join
25
26 # List all data files
27 def data():
28     r = {}
29     for root, dirnames, filenames in os.walk('openerp'):
30         for filename in filenames:
31             if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename):
32                 r.setdefault(root, []).append(os.path.join(root, filename))
33
34     if os.name == 'nt':
35         r["Microsoft.VC90.CRT"] = glob.glob('C:\Microsoft.VC90.CRT\*.*')
36
37         import babel
38         # Add data, but also some .py files py2exe won't include automatically.
39         # TODO This should probably go under `packages`, instead of `data`,
40         # but this will work fine (especially since we don't use the ZIP file
41         # approach).
42         r["babel/localedata"] = glob.glob(os.path.join(os.path.dirname(babel.__file__), "localedata", '*'))
43         others = ['global.dat', 'numbers.py', 'support.py']
44         r["babel"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), f), others)
45         others = ['frontend.py', 'mofile.py']
46         r["babel/messages"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), "messages", f), others)
47
48         import pytz
49         tzdir = os.path.dirname(pytz.__file__)
50         for root, _, filenames in os.walk(os.path.join(tzdir, "zoneinfo")):
51             base = os.path.join('pytz', root[len(tzdir) + 1:])
52             r[base] = [os.path.join(root, f) for f in filenames]
53
54         import docutils
55         dudir = os.path.dirname(docutils.__file__)
56         for root, _, filenames in os.walk(dudir):
57             base = os.path.join('docutils', root[len(dudir) + 1:])
58             r[base] = [os.path.join(root, f) for f in filenames if not f.endswith(('.py', '.pyc', '.pyo'))]
59
60     return r.items()
61
62 def gen_manifest():
63     file_list="\n".join(data())
64     open('MANIFEST','w').write(file_list)
65
66 if os.name == 'nt':
67     sys.path.append("C:\Microsoft.VC90.CRT")
68
69 def py2exe_options():
70     if os.name == 'nt':
71         import py2exe
72         return {
73             "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], }],
74             'options' : {
75                 "py2exe": {
76                     "skip_archive": 1,
77                     "optimize": 2,
78                     "dist_dir": 'dist',
79                     "packages": [ "DAV", "HTMLParser", "PIL", "asynchat", "asyncore", "commands", "dateutil", "decimal", "docutils", "email", "encodings", "imaplib", "jinja2", "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify", "mako", "openerp", "poplib", "pychart", "pydot", "pyparsing", "pytz", "reportlab", "select", "simplejson", "smtplib", "uuid", "vatnumber", "vobject", "xml", "xml.dom", "yaml", ],
80                     "excludes" : ["Tkconstants","Tkinter","tcl"],
81                 }
82             }
83         }
84     else:
85         return {}
86
87 execfile(join(os.path.dirname(__file__), 'openerp', 'release.py'))
88
89 # Notes for OpenERP developer on windows:
90 #
91 # To setup a windows developer evironement install python2.7 then pip and use
92 # "pip install <depencey>" for every dependency listed below.
93 #
94 # Dependecies that requires DLLs are not installable with pip install, for
95 # them we added comments with links where you can find the installers.
96 #
97 # OpenERP on windows also require the pywin32, the binary can be found at
98 # http://pywin32.sf.net
99 #
100 # Both python2.7 32bits and 64bits are known to work.
101
102 setuptools.setup(
103       name             = 'openerp',
104       version          = version,
105       description      = description,
106       long_description = long_desc,
107       url              = url,
108       author           = author,
109       author_email     = author_email,
110       classifiers      = filter(None, classifiers.split("\n")),
111       license          = license,
112       scripts          = ['openerp-server'],
113       data_files       = data(),
114       packages         = setuptools.find_packages(),
115       dependency_links = ['http://download.gna.org/pychart/'],
116       #include_package_data = True,
117       install_requires = [
118           'pychart', # not on pypi, use: pip install http://download.gna.org/pychart/PyChart-1.39.tar.gz
119           'babel',
120           'docutils',
121           'feedparser',
122           'gdata',
123           'Jinja2',
124           'lxml', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
125           'mako',
126           'mock',
127           'PIL', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
128           'psutil', # windows binary code.google.com/p/psutil/downloads/list
129           'psycopg2 >= 2.2',
130           'pydot',
131           'python-dateutil < 2',
132           'python-ldap', # optional
133           'python-openid',
134           'pytz',
135           'pywebdav',
136           'pyyaml',
137           'reportlab', # windows binary pypi.python.org/pypi/reportlab
138           'simplejson',
139           'unittest2',
140           'vatnumber',
141           'vobject',
142           'werkzeug',
143           'xlwt',
144       ],
145       extras_require = {
146           'SSL' : ['pyopenssl'],
147       },
148       tests_require = ['unittest2'],
149       **py2exe_options()
150 )
151
152
153 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: