1
by pinky
New trunk |
1 |
#!/usr/bin/env python
|
923
by Christophe Simonis
add encoding comment and vim comment |
2 |
# -*- encoding: utf-8 -*-
|
809
by stw
add Copyright and GPL license into the Header of Python files |
3 |
##############################################################################
|
4 |
#
|
|
1766.1.12
by Naresh Choksy
Bugfix:373230 |
5 |
# OpenERP, Open Source Management Solution
|
1556
by Stephane Wirtel
[IMP] Update the copyright to 2009 |
6 |
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
1230
by Christophe Simonis
passing in GPL-3 |
7 |
# $Id$
|
8 |
#
|
|
9 |
# This program is free software: you can redistribute it and/or modify
|
|
10 |
# it under the terms of the GNU General Public License as published by
|
|
11 |
# the Free Software Foundation, either version 3 of the License, or
|
|
12 |
# (at your option) any later version.
|
|
13 |
#
|
|
14 |
# This program is distributed in the hope that it will be useful,
|
|
15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 |
# GNU General Public License for more details.
|
|
18 |
#
|
|
19 |
# You should have received a copy of the GNU General Public License
|
|
20 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21 |
#
|
|
22 |
##############################################################################
|
|
1229
by Christophe Simonis
improvement |
23 |
|
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
24 |
# setup for OpenERP Server
|
1
by pinky
New trunk |
25 |
# taken from straw http://www.nongnu.org/straw/index.html
|
26 |
# taken from gnomolicious http://www.nongnu.org/gnomolicious/
|
|
27 |
# adapted by Nicolas Évrard <nicoe@altern.org>
|
|
28 |
||
29 |
import sys |
|
30 |
import os |
|
31 |
import glob |
|
32 |
||
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
33 |
from distutils.core import setup |
1301
by Stephane Wirtel
[FIX] Use the prefix specified by the user at the installation |
34 |
from distutils.command.install import install |
2056
by Stephane Wirtel
[FIX] Use the get_python_lib of distutils. This function is very |
35 |
from distutils.sysconfig import get_python_lib |
1
by pinky
New trunk |
36 |
|
314
by ced
SERVER: improve setup |
37 |
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin")) |
1
by pinky
New trunk |
38 |
|
39 |
opj = os.path.join |
|
40 |
||
314
by ced
SERVER: improve setup |
41 |
execfile(opj('bin', 'release.py')) |
1
by pinky
New trunk |
42 |
|
2017
by Stephane Wirtel
[FIX] In the case we want to generate the RPM package, we change the version |
43 |
if 'bdist_rpm' in sys.argv: |
1812
by Christophe Simonis
[IMP] change version number |
44 |
version = version.split('-')[0] |
1638.1.1
by Stephane Wirtel
[FIX] Redhat Package Manager |
45 |
|
1
by pinky
New trunk |
46 |
# get python short version
|
47 |
py_short_version = '%s.%s' % sys.version_info[:2] |
|
48 |
||
1246
by Stephane Wirtel
Refactor the setup.py |
49 |
required_modules = [ |
1341.1.16
by Christophe Simonis
[FIX] change setup.py to load psycopg2 |
50 |
('psycopg2', 'PostgreSQL module'), |
1252
by Stephane Wirtel
Add the dependencies |
51 |
('reportlab', 'reportlab module'), |
52 |
('pychart', 'pychart module'), |
|
53 |
('pydot', 'pydot module'), |
|
1866.2.6
by Xavier Morel
[FIX] Added lxml as required module on setup |
54 |
('lxml', 'lxml module: pythonic libxml2 and libxslt bindings'), |
1246
by Stephane Wirtel
Refactor the setup.py |
55 |
]
|
1
by pinky
New trunk |
56 |
|
57 |
def check_modules(): |
|
58 |
ok = True |
|
59 |
for modname, desc in required_modules: |
|
60 |
try: |
|
61 |
exec('import %s' % modname) |
|
62 |
except ImportError: |
|
63 |
ok = False |
|
64 |
print 'Error: python module %s (%s) is required' % (modname, desc) |
|
65 |
||
66 |
if not ok: |
|
67 |
sys.exit(1) |
|
68 |
||
69 |
def find_addons(): |
|
314
by ced
SERVER: improve setup |
70 |
for (dp, dn, names) in os.walk(opj('bin', 'addons')): |
1685
by Stephane Wirtel
[FIX] Fix the addons directory with RPM |
71 |
if '__terp__.py' in names: |
1330
by Stephane Wirtel
[FIX] Load all directories in the addons by the setup |
72 |
modname = dp.replace(os.path.sep, '.').replace('bin', 'openerp-server', 1) |
73 |
yield modname |
|
1
by pinky
New trunk |
74 |
|
75 |
def data_files(): |
|
76 |
'''Build list of data files to be installed'''
|
|
314
by ced
SERVER: improve setup |
77 |
files = [] |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
78 |
if sys.platform == 'win32': |
314
by ced
SERVER: improve setup |
79 |
os.chdir('bin') |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
80 |
for (dp, dn, names) in os.walk('addons'): |
1246
by Stephane Wirtel
Refactor the setup.py |
81 |
files.append((dp, map(lambda x: opj('bin', dp, x), names))) |
314
by ced
SERVER: improve setup |
82 |
os.chdir('..') |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
83 |
for (dp, dn, names) in os.walk('doc'): |
1246
by Stephane Wirtel
Refactor the setup.py |
84 |
files.append((dp, map(lambda x: opj(dp, x), names))) |
1451
by Stephane Wirtel
[FIX] Add some files |
85 |
files.append(('.', [opj('bin', 'import_xml.rng'), |
1766.1.12
by Naresh Choksy
Bugfix:373230 |
86 |
opj('bin', 'server.pkey'), |
1451
by Stephane Wirtel
[FIX] Add some files |
87 |
opj('bin', 'server.cert')])) |
314
by ced
SERVER: improve setup |
88 |
else: |
1246
by Stephane Wirtel
Refactor the setup.py |
89 |
man_directory = opj('share', 'man') |
90 |
files.append((opj(man_directory, 'man1'), ['man/openerp-server.1'])) |
|
91 |
files.append((opj(man_directory, 'man5'), ['man/openerp_serverrc.5'])) |
|
92 |
||
93 |
doc_directory = opj('share', 'doc', 'openerp-server-%s' % version) |
|
94 |
files.append((doc_directory, [f for f in glob.glob('doc/*') if os.path.isfile(f)])) |
|
95 |
files.append((opj(doc_directory, 'migrate', '3.3.0-3.4.0'), [f for f in glob.glob('doc/migrate/3.3.0-3.4.0/*') if os.path.isfile(f)])) |
|
96 |
files.append((opj(doc_directory, 'migrate', '3.4.0-4.0.0'), [f for f in glob.glob('doc/migrate/3.4.0-4.0.0/*') if os.path.isfile(f)])) |
|
97 |
||
2056
by Stephane Wirtel
[FIX] Use the get_python_lib of distutils. This function is very |
98 |
openerp_site_packages = opj(get_python_lib(prefix=''), 'openerp-server') |
1246
by Stephane Wirtel
Refactor the setup.py |
99 |
|
1482
by Stephane Wirtel
[FIX] Add the certificate and private key files |
100 |
files.append((openerp_site_packages, [opj('bin', 'import_xml.rng'), |
101 |
opj('bin', 'server.pkey'), |
|
102 |
opj('bin', 'server.cert')])) |
|
103 |
||
314
by ced
SERVER: improve setup |
104 |
for addon in find_addons(): |
1685
by Stephane Wirtel
[FIX] Fix the addons directory with RPM |
105 |
addonname = addon.split('.')[-1] |
1246
by Stephane Wirtel
Refactor the setup.py |
106 |
add_path = addon.replace('.', os.path.sep).replace('openerp-server', 'bin', 1) |
2056
by Stephane Wirtel
[FIX] Use the get_python_lib of distutils. This function is very |
107 |
addon_path = opj(get_python_lib(prefix=''), |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
108 |
add_path.replace('bin', 'openerp-server', 1)) |
1330
by Stephane Wirtel
[FIX] Load all directories in the addons by the setup |
109 |
pathfiles = [] |
110 |
for root, dirs, innerfiles in os.walk(add_path): |
|
1714
by Stephane Wirtel
[FIX] |
111 |
innerfiles = filter(lambda file: os.path.splitext(file)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles) |
1330
by Stephane Wirtel
[FIX] Load all directories in the addons by the setup |
112 |
if innerfiles: |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
113 |
res = os.path.normpath( |
114 |
opj(addon_path, root.replace(opj('bin', 'addons', addonname), '.')) |
|
115 |
)
|
|
1685
by Stephane Wirtel
[FIX] Fix the addons directory with RPM |
116 |
pathfiles.extend(((res, map(lambda file: opj(root, file), innerfiles)),)) |
314
by ced
SERVER: improve setup |
117 |
files.extend(pathfiles) |
1685
by Stephane Wirtel
[FIX] Fix the addons directory with RPM |
118 |
|
1
by pinky
New trunk |
119 |
return files |
120 |
||
121 |
check_modules() |
|
122 |
||
1328
by Stephane Wirtel
[FIX] setup.py build |
123 |
f = file('openerp-server','w') |
1401.1.4
by Stephane Wirtel
[FIX] Update the MANIFEST.in to include the rng files and the po files |
124 |
start_script = """#!/bin/sh\necho "OpenERP Setup - The content of this file is generated at the install stage\n" """ |
1328
by Stephane Wirtel
[FIX] setup.py build |
125 |
f.write(start_script) |
126 |
f.close() |
|
1322.1.1
by Stephane Wirtel
[FIX] Create an empty openerp-server file for the build stage |
127 |
|
1301
by Stephane Wirtel
[FIX] Use the prefix specified by the user at the installation |
128 |
class openerp_server_install(install): |
129 |
def run(self): |
|
130 |
# create startup script
|
|
131 |
start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n" % (opj(self.install_libbase, "openerp-server"), sys.executable) |
|
132 |
# write script
|
|
133 |
f = open('openerp-server', 'w') |
|
134 |
f.write(start_script) |
|
135 |
f.close() |
|
136 |
install.run(self) |
|
1
by pinky
New trunk |
137 |
|
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
138 |
complementary_arguments = dict() |
139 |
||
140 |
has_py2exe = False |
|
141 |
||
142 |
if sys.platform == 'win32': |
|
143 |
complementary_arguments['windows'] = [ |
|
144 |
{
|
|
145 |
"script" : os.path.join('bin', 'openerp-server.py'), |
|
146 |
"icon_resources" : [ (1, os.path.join('pixmaps', 'openerp-icon.ico')) ] |
|
147 |
}
|
|
148 |
]
|
|
149 |
||
150 |
import py2exe |
|
151 |
||
152 |
has_py2exe = True |
|
153 |
||
154 |
complementary_arguments['options'] = { |
|
155 |
'py2exe' : { |
|
156 |
"compressed": 1, |
|
157 |
"optimize": 2, |
|
158 |
"dist_dir": 'dist', |
|
159 |
"packages": [ |
|
160 |
"lxml", "lxml.builder", "lxml._elementpath", "lxml.etree", |
|
161 |
"lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath", |
|
162 |
"encodings", "mx.DateTime","wizard","pychart","PIL", "pyparsing", |
|
163 |
"pydot", "asyncore", "asynchat", "reportlab", "vobject", |
|
164 |
"HTMLParser", "select", "mako", "poplib", |
|
165 |
"imaplib", "smtplib", "email", |
|
166 |
],
|
|
167 |
"excludes" : ["Tkconstants","Tkinter","tcl"], |
|
168 |
}
|
|
1246
by Stephane Wirtel
Refactor the setup.py |
169 |
}
|
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
170 |
|
314
by ced
SERVER: improve setup |
171 |
|
1
by pinky
New trunk |
172 |
setup(name = name, |
173 |
version = version, |
|
314
by ced
SERVER: improve setup |
174 |
description = description, |
1
by pinky
New trunk |
175 |
long_description = long_desc, |
314
by ced
SERVER: improve setup |
176 |
url = url, |
177 |
author = author, |
|
178 |
author_email = author_email, |
|
1
by pinky
New trunk |
179 |
classifiers = filter(None, classifiers.split("\n")), |
314
by ced
SERVER: improve setup |
180 |
license = license, |
1
by pinky
New trunk |
181 |
data_files = data_files(), |
1766.1.12
by Naresh Choksy
Bugfix:373230 |
182 |
cmdclass = { |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
183 |
'install' : openerp_server_install, |
1328
by Stephane Wirtel
[FIX] setup.py build |
184 |
},
|
1072
by Stephane Wirtel
Rename Tiny ERP to OpenERP |
185 |
scripts = ['openerp-server'], |
1766.1.12
by Naresh Choksy
Bugfix:373230 |
186 |
packages = ['openerp-server', |
1246
by Stephane Wirtel
Refactor the setup.py |
187 |
'openerp-server.addons', |
1072
by Stephane Wirtel
Rename Tiny ERP to OpenERP |
188 |
'openerp-server.ir', |
189 |
'openerp-server.osv', |
|
1766.1.12
by Naresh Choksy
Bugfix:373230 |
190 |
'openerp-server.service', |
1246
by Stephane Wirtel
Refactor the setup.py |
191 |
'openerp-server.tools', |
1072
by Stephane Wirtel
Rename Tiny ERP to OpenERP |
192 |
'openerp-server.report', |
193 |
'openerp-server.report.printscreen', |
|
1724
by Stephane Wirtel
[FIX] Import the pyPdf package |
194 |
'openerp-server.report.pyPdf', |
1072
by Stephane Wirtel
Rename Tiny ERP to OpenERP |
195 |
'openerp-server.report.render', |
196 |
'openerp-server.report.render.rml2pdf', |
|
197 |
'openerp-server.report.render.rml2html', |
|
1766.1.12
by Naresh Choksy
Bugfix:373230 |
198 |
'openerp-server.wizard', |
1766.2.11
by Stephane Wirtel
[FIX] Add the odt2odt dependency in the list of the addons (patch from Dukai Gabor) |
199 |
'openerp-server.report.render.odt2odt', |
1766.1.12
by Naresh Choksy
Bugfix:373230 |
200 |
'openerp-server.report.render.html2html', |
1246
by Stephane Wirtel
Refactor the setup.py |
201 |
'openerp-server.workflow'] + \ |
1
by pinky
New trunk |
202 |
list(find_addons()), |
1072
by Stephane Wirtel
Rename Tiny ERP to OpenERP |
203 |
package_dir = {'openerp-server': 'bin'}, |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
204 |
**complementary_arguments |
205 |
)
|
|
1
by pinky
New trunk |
206 |
|
1803.1.13
by Olivier Laurent
[FIX] setup.py: py2exe now adds 'zoneinfo' directory in library.zip |
207 |
if has_py2exe: |
2049
by Stephane Wirtel
[IMP] setup.py: Rewrite some parts of the setup.py |
208 |
# Sometime between pytz-2008a and pytz-2008i common_timezones started to
|
209 |
# include only names of zones with a corresponding data file in zoneinfo.
|
|
210 |
# pytz installs the zoneinfo directory tree in the same directory
|
|
211 |
# as the pytz/__init__.py file. These data files are loaded using
|
|
212 |
# pkg_resources.resource_stream. py2exe does not copy this to library.zip so
|
|
213 |
# resource_stream can't find the files and common_timezones is empty when
|
|
214 |
# read in the py2exe executable.
|
|
215 |
# This manually copies zoneinfo into the zip. See also
|
|
216 |
# http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
|
|
217 |
import pytz |
|
218 |
import zipfile |
|
219 |
# Make sure the layout of pytz hasn't changed
|
|
220 |
assert (pytz.__file__.endswith('__init__.pyc') or |
|
221 |
pytz.__file__.endswith('__init__.py')), pytz.__file__ |
|
222 |
zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo') |
|
223 |
# '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
|
|
224 |
disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__)) |
|
225 |
zipfile_path = os.path.join(complementary_arguments['options']['py2exe']['dist_dir'], 'library.zip') |
|
226 |
z = zipfile.ZipFile(zipfile_path, 'a') |
|
227 |
||
228 |
for absdir, directories, filenames in os.walk(zoneinfo_dir): |
|
229 |
assert absdir.startswith(disk_basedir), (absdir, disk_basedir) |
|
230 |
zip_dir = absdir[len(disk_basedir):] |
|
231 |
for f in filenames: |
|
232 |
z.write(os.path.join(absdir, f), os.path.join(zip_dir, f)) |
|
233 |
||
234 |
z.close() |
|
923
by Christophe Simonis
add encoding comment and vim comment |
235 |