~openerp-dev/openobject-client-web/6.0-opw-599608-rgo

« back to all changes in this revision

Viewing changes to win32/setup.py

  • Committer: Xavier Morel
  • Date: 2010-11-08 13:21:12 UTC
  • mfrom: (3784.1.6 trunk)
  • Revision ID: xmo@openerp.com-20101108132112-al0aostzkpjvh1by
[IMP] new win32 service spec (to be merged into root setup.py/py2exe), new NSIS script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import sys
 
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
##############################################################################
3
21
 
4
22
from distutils.core import setup
5
 
from distutils.core import Command
6
 
from distutils.errors import *
7
 
 
8
 
import fnmatch
9
 
import util
10
 
 
11
 
URLS = {
12
 
    "python": ("http://www.python.org/ftp/python/2.5.4/python-2.5.4.msi", "python-2.5.4.msi"),
13
 
    "ez_setup": ("http://peak.telecommunity.com/dist/ez_setup.py", "ez_setup.py"),
14
 
    "pywin32": ("http://nchc.dl.sourceforge.net/sourceforge/pywin32/pywin32-212.win32-py2.5.exe", "pywin32-212.win32-py2.5.exe")
15
 
}
16
 
 
17
 
BUILD_DIR=os.path.join(os.path.dirname(os.path.abspath(__file__)), "build")
18
 
PYDIR=os.path.join(BUILD_DIR, "python25")
19
 
 
20
 
execfile(os.path.join("openobject", "release.py"))
21
 
 
22
 
class bdist_wininst(Command):
23
 
    user_options = [('allinone', None, 'Generate the windows installer for the All In One')]
24
 
 
25
 
    def initialize_options (self):
26
 
        self.allinone = None
27
 
 
28
 
    def finalize_options (self):
29
 
        pass
30
 
 
31
 
    def run (self):
32
 
 
33
 
        if (sys.platform != "win32"):
34
 
            raise DistutilsPlatformError("Distribution must be compiled on a Windows 32 platform")
35
 
 
36
 
        if not os.path.exists(BUILD_DIR):
37
 
            os.mkdir(BUILD_DIR)
38
 
 
39
 
        # change to the build dir
40
 
        os.chdir(BUILD_DIR)
41
 
 
42
 
        self._check_python()
43
 
        self._check_setuptools()
44
 
        self._check_pywin32()
45
 
        self._check_openerp_web()
46
 
        self._check_fixps()
47
 
 
48
 
        for package in [
49
 
            ('cherrypy', 'CherryPy >= 3.1.2'),
50
 
            ('mako', 'mako >= 0.2.4'),
51
 
            ('babel', 'Babel >= 0.9.4'),
52
 
            ('formencode', 'FormEncode >= 1.2.2'),
53
 
            ('simplejson', 'simplejson >= 2.0.9'),
54
 
            ('dateutil', 'python-dateutil >= 1.4.1'),
55
 
            ('pytz', 'pytz >= 2009j')
56
 
            ]:
57
 
            self._check_package(*package)
58
 
 
59
 
        # finally compile the setup.nsi
60
 
        self._make_nsis()
61
 
 
62
 
    def run_py(self, *args):
63
 
        return not os.system(PYDIR + "\\python.exe " + " ".join(args))
64
 
 
65
 
    def run_ez(self, *args):
66
 
        return not os.system(PYDIR + "\\Scripts\\easy_install.exe -Z " + " ".join(args))
67
 
 
68
 
    def check_module(self, module):
69
 
        return self.run_py('-c', '"import %s"' % module)
70
 
 
71
 
    def _check_python(self):
72
 
 
73
 
        if os.path.exists(os.path.join(PYDIR, "python.exe")):
74
 
            return True
75
 
 
76
 
        url, name = URLS['python']
77
 
        util.download(url)
78
 
 
79
 
        print "Extracting the the python installer..."
80
 
        os.system('msiexec /a %s /qn TARGETDIR="%s"' % (name, PYDIR))
81
 
 
82
 
    def _check_setuptools(self):
83
 
 
84
 
        if self.check_module("setuptools"):
85
 
            return
86
 
 
87
 
        url, name = URLS['ez_setup']
88
 
        util.download(url)
89
 
 
90
 
        self.run_py(name)
91
 
 
92
 
    def _check_pywin32(self):
93
 
 
94
 
        if self.check_module("pywintypes"):
95
 
            return
96
 
 
97
 
        url, name = URLS['pywin32']
98
 
        util.download(url, name)
99
 
 
100
 
        util.unzip(name, 'tmp_pyw32')
101
 
 
102
 
        os.system("xcopy /q /y /e tmp_pyw32\\PLATLIB\\* \"%s\\Lib\\site-packages\"" % PYDIR)
103
 
        os.system("copy /y \"%s\\Lib\\site-packages\\pywin32_system32\\*\" \"%s\"" % (PYDIR, PYDIR))
104
 
        os.system("copy /y \"%s\\Lib\\site-packages\\win32\\*.exe\" \"%s\"" % (PYDIR, PYDIR))
105
 
        os.system("copy /y \"%s\\Lib\\site-packages\\win32\\*.dll\" \"%s\"" % (PYDIR, PYDIR))
106
 
        os.system("rmdir /s /q tmp_pyw32")
107
 
 
108
 
    def _check_package(self, package, dependency):
109
 
        if self.check_module(package):
110
 
            return
111
 
        self.run_ez(dependency)
112
 
 
113
 
    def _check_pyparsing(self):
114
 
 
115
 
        if self.check_module("pyparsing"):
116
 
            return
117
 
 
118
 
        url, name = URLS['pyparsing']
119
 
        util.download(url, name)
120
 
 
121
 
        self.run_ez(name)
122
 
 
123
 
    def _check_openerp_web(self):
124
 
 
125
 
        if self.check_module("openobject"):
126
 
            # remove old version
127
 
            self.run_ez("-m", "openerp-web")
128
 
 
129
 
            for f in os.listdir("%s\\Scripts" % PYDIR):
130
 
                if fnmatch.fnmatch(f, "*openerp-web*"):
131
 
                    os.remove(os.path.join(PYDIR, "Scripts", f))
132
 
 
133
 
            for f in os.listdir("%s\\Lib\\site-packages" % PYDIR):
134
 
                if fnmatch.fnmatch(f, "openerp_web*"):
135
 
                    os.system("rd /s /q \"%s\\Lib\\site-packages\\%s\"" %(PYDIR, f))
136
 
 
137
 
        self.run_ez("-N", "..\\..")
138
 
 
139
 
    def _check_fixps(self):
140
 
        os.system("copy /y ..\\fixps.py \"%s\\Scripts\"" % PYDIR)
141
 
 
142
 
    def _make_nsis(self):
143
 
 
144
 
        #TODO: read registry
145
 
        makensis = "C:\\Program Files\\NSIS\\makensis.exe"
146
 
        if not os.path.exists(makensis):
147
 
            makensis = "makensis.exe"
148
 
 
149
 
        cmd = '"%s" %s /DVERSION=%s ..\\setup.nsi' % (makensis,
150
 
                                                      self.allinone and '/DALLINONE=1' or '',
151
 
                                                      version,)
152
 
 
153
 
        os.system(cmd)
154
 
 
155
 
setup(cmdclass={'bdist_wininst': bdist_wininst})
 
23
import py2exe
 
24
 
 
25
 
 
26
setup(service=["OpenERPWebService"],
 
27
      options={"py2exe":{"excludes":["Tkconstants","Tkinter","tcl",
 
28
                                     "_imagingtk","PIL._imagingtk",
 
29
                                     "ImageTk", "PIL.ImageTk",
 
30
                                     "FixTk"],
 
31
                         "compressed": 1}}
 
32
      )
 
33
 
 
34
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
156
35