1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20
##############################################################################
4
22
from distutils.core import setup
5
from distutils.core import Command
6
from distutils.errors import *
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")
17
BUILD_DIR=os.path.join(os.path.dirname(os.path.abspath(__file__)), "build")
18
PYDIR=os.path.join(BUILD_DIR, "python25")
20
execfile(os.path.join("openobject", "release.py"))
22
class bdist_wininst(Command):
23
user_options = [('allinone', None, 'Generate the windows installer for the All In One')]
25
def initialize_options (self):
28
def finalize_options (self):
33
if (sys.platform != "win32"):
34
raise DistutilsPlatformError("Distribution must be compiled on a Windows 32 platform")
36
if not os.path.exists(BUILD_DIR):
39
# change to the build dir
43
self._check_setuptools()
45
self._check_openerp_web()
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')
57
self._check_package(*package)
59
# finally compile the setup.nsi
62
def run_py(self, *args):
63
return not os.system(PYDIR + "\\python.exe " + " ".join(args))
65
def run_ez(self, *args):
66
return not os.system(PYDIR + "\\Scripts\\easy_install.exe -Z " + " ".join(args))
68
def check_module(self, module):
69
return self.run_py('-c', '"import %s"' % module)
71
def _check_python(self):
73
if os.path.exists(os.path.join(PYDIR, "python.exe")):
76
url, name = URLS['python']
79
print "Extracting the the python installer..."
80
os.system('msiexec /a %s /qn TARGETDIR="%s"' % (name, PYDIR))
82
def _check_setuptools(self):
84
if self.check_module("setuptools"):
87
url, name = URLS['ez_setup']
92
def _check_pywin32(self):
94
if self.check_module("pywintypes"):
97
url, name = URLS['pywin32']
98
util.download(url, name)
100
util.unzip(name, 'tmp_pyw32')
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")
108
def _check_package(self, package, dependency):
109
if self.check_module(package):
111
self.run_ez(dependency)
113
def _check_pyparsing(self):
115
if self.check_module("pyparsing"):
118
url, name = URLS['pyparsing']
119
util.download(url, name)
123
def _check_openerp_web(self):
125
if self.check_module("openobject"):
127
self.run_ez("-m", "openerp-web")
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))
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))
137
self.run_ez("-N", "..\\..")
139
def _check_fixps(self):
140
os.system("copy /y ..\\fixps.py \"%s\\Scripts\"" % PYDIR)
142
def _make_nsis(self):
145
makensis = "C:\\Program Files\\NSIS\\makensis.exe"
146
if not os.path.exists(makensis):
147
makensis = "makensis.exe"
149
cmd = '"%s" %s /DVERSION=%s ..\\setup.nsi' % (makensis,
150
self.allinone and '/DALLINONE=1' or '',
155
setup(cmdclass={'bdist_wininst': bdist_wininst})
26
setup(service=["OpenERPWebService"],
27
options={"py2exe":{"excludes":["Tkconstants","Tkinter","tcl",
28
"_imagingtk","PIL._imagingtk",
29
"ImageTk", "PIL.ImageTk",
34
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: