# taken from gnomolicious http://www.nongnu.org/gnomolicious/
# adapted by Nicolas Évrard <nicoe@altern.org>
#
+# doc/migrate is not included since about 6.1-dev
+# doc/tests is not included
+# python25-compat/*py should be in the openerp (and imported appropriately)
import sys
import os
-from os.path import join, isfile, basename
+from os.path import join, isfile
import glob
-from pprint import pprint as pp
-
from setuptools import setup, find_packages
-from setuptools.command.install import install
-from distutils.sysconfig import get_python_lib
-
-has_py2exe = False
-if os.name == 'nt':
- import py2exe
- has_py2exe = True
-
-execfile(join('openerp', 'release.py'))
-
-if 'bdist_rpm' in sys.argv:
- version = version.split('-')[0]
-
-# get python short version
-py_short_version = '%s.%s' % sys.version_info[:2]
-# backports os.walk with followlinks from python 2.6
+# Backports os.walk with followlinks from python 2.6.
+# Needed to add all addons files to data_files for Windows packaging.
def walk_followlinks(top, topdown=True, onerror=None, followlinks=False):
from os.path import join, isdir, islink
from os import listdir, error
if sys.version_info < (2, 6):
os.walk = walk_followlinks
-def find_addons():
- for root, _, names in os.walk(join('openerp', 'addons'), followlinks=True):
- if '__openerp__.py' in names or '__terp__.py' in names:
- yield basename(root), root
- #look for extra modules
- try:
- empath = os.getenv('EXTRA_MODULES_PATH', '../addons/')
- for mname in open(join(empath, 'server_modules.list')):
- mname = mname.strip()
- if not mname:
- continue
-
- terp = join(empath, mname, '__openerp__.py')
- if not os.path.exists(terp):
- terp = join(empath, mname, '__terp__.py')
-
- if os.path.exists(terp):
- yield mname, join(empath, mname)
- else:
- print "Module %s specified, but no valid path." % mname
- except Exception:
- pass
-
-def data_files():
- '''Build list of data files to be installed'''
- files = []
- if os.name == 'nt':
+py2exe_keywords = {}
+py2exe_data_files = []
+if os.name == 'nt':
+ import py2exe
+ py2exe_keywords['console'] = [
+ { "script": "openerp-server",
+ "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))],
+ }]
+ py2exe_keywords['options'] = {
+ "py2exe": {
+ "skip_archive": 1,
+ "optimize": 2,
+ "dist_dir": 'dist',
+ "packages": [
+ "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
+ "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
+ "encodings", "dateutil", "pychart", "PIL", "pyparsing",
+ "pydot", "asyncore","asynchat", "reportlab", "vobject",
+ "HTMLParser", "select", "mako", "poplib",
+ "imaplib", "smtplib", "email", "yaml", "DAV",
+ "uuid", "commands", "openerp",
+ ],
+ "excludes" : ["Tkconstants","Tkinter","tcl"],
+ }
+ }
+ # TODO is it still necessary now that we don't use the library.zip file?
+ def data_files():
+ '''For Windows, we consider all the addons as data files.
+ It seems also that package_data below isn't honored by py2exe.'''
+ files = []
os.chdir('openerp')
for (dp, dn, names) in os.walk('addons'):
- files.append((dp, map(lambda x: join('openerp', dp, x), names)))
+ files.append((join('openerp',dp), map(lambda x: join('openerp', dp, x), names)))
os.chdir('..')
- #for root, _, names in os.walk(join('bin','addons')):
- # files.append((root, [join(root, name) for name in names]))
- for root, _, names in os.walk('doc'):
- files.append((root, [join(root, name) for name in names]))
- #for root, _, names in os.walk('pixmaps'):
- # files.append((root, [join(root, name) for name in names]))
- files.append(('.', [join('openerp', 'import_xml.rng'),]))
- else:
- 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']))
+ files.append(('openerp', [join('openerp', 'import_xml.rng'),]))
- doc_directory = join('share', 'doc', 'openerp-server-%s' % version)
- 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/*'))))
+ # copy pytz/timzeone
+ # TODO check if we have to also copy dateutil's timezone data.
+ import pytz
+ # Make sure the layout of pytz hasn't changed
+ assert (pytz.__file__.endswith('__init__.pyc') or
+ pytz.__file__.endswith('__init__.py')), pytz.__file__
+ pytz_dir = os.path.dirname(pytz.__file__)
- openerp_site_packages = join(get_python_lib(prefix=''), 'openerp')
+ saved_dir = os.getcwd()
+ os.chdir(pytz_dir)
+ for dp, dn, names in os.walk('zoneinfo'):
+ files.append((join('pytz',dp), map(lambda x: join(pytz_dir, dp, x), names)))
+ os.chdir(saved_dir)
- files.append((openerp_site_packages, [join('openerp', 'import_xml.rng'),]))
+ return files
+ py2exe_data_files = data_files()
- if sys.version_info[0:2] == (2,5):
- files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'),
- join('python25-compat','SimpleXMLRPCServer.py'),
- join('python25-compat','SocketServer.py')]))
-
- for addonname, add_path in find_addons():
- addon_path = join(get_python_lib(prefix=''), 'openerp','addons', addonname)
- for root, dirs, innerfiles in os.walk(add_path):
- innerfiles = filter(lambda fil: os.path.splitext(fil)[1] not in ('.pyc', '.pyd', '.pyo'), innerfiles)
- if innerfiles:
- res = os.path.normpath(join(addon_path, root.replace(join(add_path), '.')))
- files.extend(((res, map(lambda fil: join(root, fil),
- innerfiles)),))
-
- return files
-
-f = file('openerp-server','w')
-f.write("""#!/bin/sh
-echo "Error: the content of this file should have been replaced during "
-echo "installation\n"
-exit 1
-""")
-f.close()
-
-def find_package_dirs():
- package_dirs = {'openerp': 'openerp'}
- for mod, path in find_addons():
- package_dirs['openerp.addons.' + mod] = path
- return package_dirs
-
-class openerp_server_install(install):
- def run(self):
- # create startup script TODO not correct since the openerp lib was made
- start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n"\
- % (join(self.install_libbase, "openerp"), sys.executable)
- # write script
- f = open('openerp-server', 'w')
- f.write(start_script)
- f.close()
- install.run(self)
-
-
-
-options = {
- "py2exe": {
- "compressed": 1,
- "optimize": 2,
- "dist_dir": 'dist',
- "packages": [
- "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
- "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
- "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing",
- "pydot", "asyncore","asynchat", "reportlab", "vobject",
- "HTMLParser", "select", "mako", "poplib",
- "imaplib", "smtplib", "email", "yaml", "DAV",
- "uuid",
- ],
- "excludes" : ["Tkconstants","Tkinter","tcl"],
- }
-}
+execfile(join('openerp', 'release.py'))
setup(name = name,
version = version,
author_email = author_email,
classifiers = filter(None, classifiers.split("\n")),
license = license,
- data_files = data_files(),
- cmdclass = {
- 'install' : openerp_server_install,
- },
+ data_files = [
+ (join('man', 'man1'), ['man/openerp-server.1']),
+ (join('man', 'man5'), ['man/openerp_serverrc.5']),
+ ('doc', filter(isfile, glob.glob('doc/*'))),
+ ] + py2exe_data_files,
scripts = ['openerp-server'],
- packages = [
- '.'.join(['openerp'] + package.split('.')[1:])
- for package in find_packages()
- ],
+ packages = find_packages(),
include_package_data = True,
package_data = {
'': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'],
},
- package_dir = find_package_dirs(),
- console = [
- {
- "script": "openerp-server.py",
- "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))]
- }
- ],
- options = options,
+ dependency_links = ['http://download.gna.org/pychart/'],
install_requires = [
- 'lxml',
+ # We require the same version as caldav for lxml.
+ 'lxml==2.1.5',
'mako',
'python-dateutil',
'psycopg2',
+ # TODO the pychart package we include in openerp corresponds to PyChart 1.37.
+ # It seems there is a single difference, which is a spurious print in generate_docs.py.
+ # It is probably safe to move to PyChart 1.39 (the latest one).
+ # (Let setup.py choose the latest one, and we should check we can remove pychart from
+ # our tree.)
'pychart',
'pydot',
'pytz',
'pyyaml',
'pywebdav',
'feedparser',
+ 'simplejson >= 2.0',
],
- extras_require={
+ extras_require = {
'SSL' : ['pyopenssl'],
- }
+ },
+ **py2exe_keywords
)