packaging win32
[odoo/odoo.git] / win32 / setup.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import os
23 import glob
24 from distutils.core import setup
25 import py2exe
26
27
28 meta = {}
29 execfile(os.path.join(os.path.dirname(__file__), '..', 'openerp', 'release.py'), meta)
30
31 def generate_files():
32     actions = {
33         'start': ['stop', 'start'],
34         'stop': ['stop'],
35     }
36
37     files = []
38     if os.name == 'nt':
39         files.append(("Microsoft.VC90.CRT", glob.glob('C:\Microsoft.VC90.CRT\*.*')))
40     for action, steps in actions.items():
41         fname = action + '.bat'
42         files.append(fname)
43         with open(fname, 'w') as fp:
44             fp.write('@PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;.\n')
45             for step in steps:
46                 fp.write('@net %s %s\n' % (step, meta['nt_service_name']))
47
48     files.append('meta.py')
49     with open('meta.py', 'w') as fp:
50         for m in 'description serie nt_service_name'.split():
51             fp.write("%s = %r\n" % (m, meta[m],))
52
53     return files
54
55 excludes = "Tkconstants Tkinter tcl _imagingtk PIL._imagingtk ImageTk PIL.ImageTk FixTk".split()
56
57 setup(service      = ["OpenERPServerService"],
58       version      = meta['version'],
59       license      = meta['license'],
60       url          = meta['url'],
61       author       = meta['author'],
62       author_email = meta['author_email'],
63       data_files   = generate_files(),
64       options      = {"py2exe": {
65                         "excludes": excludes,
66                         "skip_archive": 1,
67                         "optimize": 2,
68                      }},
69       )
70
71 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: