2006-12-07 13:41:40 +00:00
|
|
|
#!/usr/bin/env python
|
2009-10-20 10:52:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-06-16 11:00:21 +00:00
|
|
|
##############################################################################
|
2009-12-12 15:24:04 +00:00
|
|
|
#
|
2009-05-07 13:35:26 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2009-10-14 12:32:15 +00:00
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 12:32:15 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-10-14 12:32:15 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2009-10-14 12:32:15 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2009-12-12 15:24:04 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
##############################################################################
|
2008-11-03 18:20:13 +00:00
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
# setup from TinERP
|
|
|
|
# taken from straw http://www.nongnu.org/straw/index.html
|
|
|
|
# taken from gnomolicious http://www.nongnu.org/gnomolicious/
|
|
|
|
# adapted by Nicolas Évrard <nicoe@altern.org>
|
|
|
|
#
|
|
|
|
|
|
|
|
import imp
|
|
|
|
import sys
|
|
|
|
import os
|
2009-12-12 16:29:22 +00:00
|
|
|
from os.path import join, isfile, basename
|
2006-12-07 13:41:40 +00:00
|
|
|
import glob
|
|
|
|
|
|
|
|
from distutils.core import setup, Command
|
2008-11-25 13:23:25 +00:00
|
|
|
from distutils.command.install import install
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2009-07-24 07:01:14 +00:00
|
|
|
has_py2exe = False
|
2007-06-13 14:15:32 +00:00
|
|
|
if os.name == 'nt':
|
|
|
|
import py2exe
|
2009-07-24 07:01:14 +00:00
|
|
|
has_py2exe = True
|
2007-06-13 14:15:32 +00:00
|
|
|
|
2009-12-12 16:06:21 +00:00
|
|
|
sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2009-12-12 16:06:21 +00:00
|
|
|
execfile(join('bin', 'release.py'))
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2009-08-14 10:38:37 +00:00
|
|
|
if sys.argv[1] == 'bdist_rpm':
|
|
|
|
version = version.split('-')[0]
|
2009-01-23 12:14:04 +00:00
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
# get python short version
|
|
|
|
py_short_version = '%s.%s' % sys.version_info[:2]
|
|
|
|
|
2008-11-13 10:29:37 +00:00
|
|
|
required_modules = [
|
2009-12-12 15:24:04 +00:00
|
|
|
('lxml', 'lxml module: pythonic libxml2 and libxslt bindings'),
|
2009-12-12 15:53:06 +00:00
|
|
|
('mx', "egenix's mx library for its extended DateTime module"),
|
2008-12-08 14:04:45 +00:00
|
|
|
('psycopg2', 'PostgreSQL module'),
|
2008-11-14 15:09:32 +00:00
|
|
|
('pychart', 'pychart module'),
|
|
|
|
('pydot', 'pydot module'),
|
2009-12-12 15:53:06 +00:00
|
|
|
('pytz', 'Timezone handling library for Python'),
|
2009-12-12 15:24:04 +00:00
|
|
|
('reportlab', 'reportlab module'),
|
2008-11-13 10:29:37 +00:00
|
|
|
]
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
def check_modules():
|
2009-12-12 16:02:37 +00:00
|
|
|
errors = []
|
2006-12-07 13:41:40 +00:00
|
|
|
for modname, desc in required_modules:
|
|
|
|
try:
|
2009-12-12 16:00:04 +00:00
|
|
|
imp.find_module(modname)
|
2006-12-07 13:41:40 +00:00
|
|
|
except ImportError:
|
2009-12-12 16:02:37 +00:00
|
|
|
errors.append(
|
|
|
|
'Error: python module %s (%s) is required' % (modname, desc))
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2009-12-12 16:02:37 +00:00
|
|
|
if errors:
|
|
|
|
print '\n'.join(errors)
|
2006-12-07 13:41:40 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2009-12-12 16:18:00 +00:00
|
|
|
def find_addons():
|
2009-12-12 16:29:22 +00:00
|
|
|
for dp, dn, names in os.walk(join('bin', 'addons')):
|
2009-02-03 18:42:35 +00:00
|
|
|
if '__terp__.py' in names:
|
2009-12-12 16:29:22 +00:00
|
|
|
yield basename(dp), dp
|
2009-06-10 19:33:35 +00:00
|
|
|
#look for extra modules
|
|
|
|
try:
|
|
|
|
empath = os.getenv('EXTRA_MODULES_PATH','../addons/')
|
2009-12-12 16:21:14 +00:00
|
|
|
for mname in open(join(empath,'server_modules.list')):
|
2009-06-10 19:33:35 +00:00
|
|
|
mname = mname.strip()
|
|
|
|
if not mname:
|
|
|
|
continue
|
2009-12-12 16:06:21 +00:00
|
|
|
if os.path.exists(join(empath,mname,'__terp__.py')):
|
2009-12-12 16:29:22 +00:00
|
|
|
yield mname, join(empath,mname)
|
2009-06-10 19:33:35 +00:00
|
|
|
else:
|
|
|
|
print "Module %s specified, but no valid path." % mname
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
def data_files():
|
|
|
|
'''Build list of data files to be installed'''
|
2007-06-13 14:15:32 +00:00
|
|
|
files = []
|
|
|
|
if os.name == 'nt':
|
2009-12-12 16:29:22 +00:00
|
|
|
for dp,dn,names in os.walk(join('bin','addons')):
|
2009-12-12 16:13:14 +00:00
|
|
|
files.append((dp, map(lambda x: join(dp, x), names)))
|
2009-12-12 16:29:22 +00:00
|
|
|
for dp,dn,names in os.walk('doc'):
|
2009-12-12 16:06:21 +00:00
|
|
|
files.append((dp, map(lambda x: join(dp, x), names)))
|
|
|
|
files.append(('.', [join('bin', 'import_xml.rng'),
|
|
|
|
join('bin', 'server.pkey'),
|
|
|
|
join('bin', 'server.cert')]))
|
2007-06-13 14:15:32 +00:00
|
|
|
else:
|
2009-12-12 16:06:21 +00:00
|
|
|
man_directory = join('share', 'man')
|
|
|
|
files.append((join(man_directory, 'man1'), ['man/openerp-server.1']))
|
|
|
|
files.append((join(man_directory, 'man5'), ['man/openerp_serverrc.5']))
|
2008-11-13 10:29:37 +00:00
|
|
|
|
2009-12-12 16:06:21 +00:00
|
|
|
doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
|
2009-12-12 16:09:59 +00:00
|
|
|
files.append((doc_directory, filter(isfile, glob.glob('doc/*'))))
|
|
|
|
files.append((join(doc_directory, 'migrate', '3.3.0-3.4.0'),
|
|
|
|
filter(isfile, glob.glob('doc/migrate/3.3.0-3.4.0/*'))))
|
|
|
|
files.append((join(doc_directory, 'migrate', '3.4.0-4.0.0'),
|
|
|
|
filter(isfile, glob.glob('doc/migrate/3.4.0-4.0.0/*'))))
|
2008-11-13 10:29:37 +00:00
|
|
|
|
2009-12-12 16:06:21 +00:00
|
|
|
openerp_site_packages = join('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server')
|
2008-11-13 10:29:37 +00:00
|
|
|
|
2009-12-12 16:06:21 +00:00
|
|
|
files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
|
|
|
|
join('bin', 'server.pkey'),
|
|
|
|
join('bin', 'server.cert')]))
|
2008-12-22 19:18:22 +00:00
|
|
|
|
2009-09-10 00:02:41 +00:00
|
|
|
if sys.version_info[0:2] == (2,5):
|
2009-12-12 16:06:21 +00:00
|
|
|
files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
|
|
|
|
join('python25-compat','SimpleXMLRPCServer.py'),
|
|
|
|
join('python25-compat','SocketServer.py')]))
|
2009-09-10 00:02:41 +00:00
|
|
|
|
2009-12-12 16:29:22 +00:00
|
|
|
for addonname, add_path in find_addons():
|
2009-12-12 16:06:21 +00:00
|
|
|
addon_path = join('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server','addons', addonname)
|
2008-12-01 11:38:48 +00:00
|
|
|
for root, dirs, innerfiles in os.walk(add_path):
|
2009-06-10 19:33:35 +00:00
|
|
|
innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
|
2008-12-01 11:38:48 +00:00
|
|
|
if innerfiles:
|
2009-12-12 16:06:21 +00:00
|
|
|
res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
|
2009-12-12 16:29:22 +00:00
|
|
|
files.extend(((res, map(lambda fil: join(root, fil),
|
|
|
|
innerfiles)),))
|
2009-02-03 18:42:35 +00:00
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
return files
|
|
|
|
|
2009-12-12 16:29:22 +00:00
|
|
|
if not os.getenv('NO_CHECK_MODULES') :
|
2009-06-10 17:35:24 +00:00
|
|
|
check_modules()
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2008-11-29 07:54:39 +00:00
|
|
|
f = file('openerp-server','w')
|
2009-12-12 16:29:22 +00:00
|
|
|
f.write("""#!/bin/sh
|
2009-12-12 16:33:05 +00:00
|
|
|
echo "Error: the content of this file should have been replaced during "
|
|
|
|
echo "installation\n"
|
|
|
|
exit 1
|
2009-12-12 16:29:22 +00:00
|
|
|
""")
|
2008-11-29 07:54:39 +00:00
|
|
|
f.close()
|
2008-11-28 14:09:52 +00:00
|
|
|
|
2009-06-10 19:33:35 +00:00
|
|
|
def find_package_dirs():
|
|
|
|
res = {}
|
2009-12-12 16:29:22 +00:00
|
|
|
for mod, path in find_addons():
|
2009-06-10 19:33:35 +00:00
|
|
|
res ['openerp-server.addons.'+ mod ] = path
|
|
|
|
res ['openerp-server'] = 'bin'
|
|
|
|
return res
|
|
|
|
|
2008-11-25 13:23:25 +00:00
|
|
|
class openerp_server_install(install):
|
|
|
|
def run(self):
|
|
|
|
# create startup script
|
2009-12-12 16:06:21 +00:00
|
|
|
start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n" % (join(self.install_libbase, "openerp-server"), sys.executable)
|
2008-11-25 13:23:25 +00:00
|
|
|
# write script
|
|
|
|
f = open('openerp-server', 'w')
|
|
|
|
f.write(start_script)
|
|
|
|
f.close()
|
|
|
|
install.run(self)
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2008-11-13 10:29:37 +00:00
|
|
|
options = {
|
|
|
|
"py2exe": {
|
2008-11-21 14:04:46 +00:00
|
|
|
"compressed": 1,
|
2009-05-07 13:35:26 +00:00
|
|
|
"optimize": 2,
|
2009-07-24 07:01:14 +00:00
|
|
|
"dist_dir": 'dist',
|
2009-05-07 13:35:26 +00:00
|
|
|
"packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
|
|
|
|
"lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath",
|
|
|
|
"encodings","mx.DateTime","wizard","pychart","PIL", "pyparsing",
|
2009-12-12 15:24:04 +00:00
|
|
|
"pydot","asyncore","asynchat", "reportlab", "vobject",
|
2009-01-03 01:05:00 +00:00
|
|
|
"HTMLParser", "select"],
|
2008-11-13 10:29:37 +00:00
|
|
|
"excludes" : ["Tkconstants","Tkinter","tcl"],
|
|
|
|
}
|
|
|
|
}
|
2007-06-13 14:15:32 +00:00
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
setup(name = name,
|
|
|
|
version = version,
|
2007-06-13 14:15:32 +00:00
|
|
|
description = description,
|
2006-12-07 13:41:40 +00:00
|
|
|
long_description = long_desc,
|
2007-06-13 14:15:32 +00:00
|
|
|
url = url,
|
|
|
|
author = author,
|
|
|
|
author_email = author_email,
|
2006-12-07 13:41:40 +00:00
|
|
|
classifiers = filter(None, classifiers.split("\n")),
|
2007-06-13 14:15:32 +00:00
|
|
|
license = license,
|
2006-12-07 13:41:40 +00:00
|
|
|
data_files = data_files(),
|
2009-05-07 13:35:26 +00:00
|
|
|
cmdclass = {
|
2008-11-29 07:54:39 +00:00
|
|
|
'install' : openerp_server_install,
|
|
|
|
},
|
2008-09-10 08:46:40 +00:00
|
|
|
scripts = ['openerp-server'],
|
2009-05-07 13:35:26 +00:00
|
|
|
packages = ['openerp-server',
|
2008-11-13 10:29:37 +00:00
|
|
|
'openerp-server.addons',
|
2008-09-10 08:46:40 +00:00
|
|
|
'openerp-server.ir',
|
2009-12-12 15:35:09 +00:00
|
|
|
'openerp-server.mako',
|
2008-09-10 08:46:40 +00:00
|
|
|
'openerp-server.osv',
|
2009-12-12 15:26:31 +00:00
|
|
|
'openerp-server.pychart',
|
2008-09-10 08:46:40 +00:00
|
|
|
'openerp-server.report',
|
|
|
|
'openerp-server.report.printscreen',
|
2009-02-12 23:39:46 +00:00
|
|
|
'openerp-server.report.pyPdf',
|
2008-09-10 08:46:40 +00:00
|
|
|
'openerp-server.report.render',
|
2009-12-12 15:25:13 +00:00
|
|
|
'openerp-server.report.render.html2html',
|
2009-12-12 15:26:31 +00:00
|
|
|
'openerp-server.report.render.makohtml2html',
|
2009-12-12 15:25:13 +00:00
|
|
|
'openerp-server.report.render.odt2odt',
|
2008-09-10 08:46:40 +00:00
|
|
|
'openerp-server.report.render.rml2html',
|
2009-12-12 15:25:13 +00:00
|
|
|
'openerp-server.report.render.rml2pdf',
|
2009-05-21 11:33:11 +00:00
|
|
|
'openerp-server.report.render.rml2txt',
|
2009-12-12 15:25:13 +00:00
|
|
|
'openerp-server.service',
|
|
|
|
'openerp-server.tools',
|
2009-05-07 13:35:26 +00:00
|
|
|
'openerp-server.wizard',
|
2008-11-13 10:29:37 +00:00
|
|
|
'openerp-server.workflow'] + \
|
2009-06-10 19:33:35 +00:00
|
|
|
list(map( lambda (a, p): 'openerp-server.addons.'+ a ,find_addons())),
|
|
|
|
package_dir = find_package_dirs(),
|
2008-12-15 10:10:13 +00:00
|
|
|
console = [ { "script" : "bin\\openerp-server.py", "icon_resources" : [ (1,"pixmaps\\openerp-icon.ico") ] } ],
|
2007-06-13 14:15:32 +00:00
|
|
|
options = options,
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
|
2009-07-24 07:01:14 +00:00
|
|
|
if has_py2exe:
|
|
|
|
# Sometime between pytz-2008a and pytz-2008i common_timezones started to
|
|
|
|
# include only names of zones with a corresponding data file in zoneinfo.
|
|
|
|
# pytz installs the zoneinfo directory tree in the same directory
|
|
|
|
# as the pytz/__init__.py file. These data files are loaded using
|
|
|
|
# pkg_resources.resource_stream. py2exe does not copy this to library.zip so
|
|
|
|
# resource_stream can't find the files and common_timezones is empty when
|
|
|
|
# read in the py2exe executable.
|
|
|
|
# This manually copies zoneinfo into the zip. See also
|
|
|
|
# http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
|
|
|
|
import pytz
|
|
|
|
import zipfile
|
|
|
|
# Make sure the layout of pytz hasn't changed
|
|
|
|
assert (pytz.__file__.endswith('__init__.pyc') or
|
|
|
|
pytz.__file__.endswith('__init__.py')), pytz.__file__
|
2009-12-12 16:06:21 +00:00
|
|
|
zoneinfo_dir = join(os.path.dirname(pytz.__file__), 'zoneinfo')
|
2009-07-24 07:01:14 +00:00
|
|
|
# '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
|
|
|
|
disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
|
2009-12-12 16:06:21 +00:00
|
|
|
zipfile_path = join(options['py2exe']['dist_dir'], 'library.zip')
|
2009-07-24 07:01:14 +00:00
|
|
|
z = zipfile.ZipFile(zipfile_path, 'a')
|
|
|
|
for absdir, directories, filenames in os.walk(zoneinfo_dir):
|
|
|
|
assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
|
|
|
|
zip_dir = absdir[len(disk_basedir):]
|
|
|
|
for f in filenames:
|
2009-12-12 16:06:21 +00:00
|
|
|
z.write(join(absdir, f), join(zip_dir, f))
|
2009-07-24 07:01:14 +00:00
|
|
|
z.close()
|
2008-07-23 15:01:27 +00:00
|
|
|
|