X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=setup.py;h=28badaff8f87f1349b47e33f8b8989ed8ef486e5;hb=663b5199cd7305c31530342bfd606e6dee7ceea0;hp=587078eb4b5737743f0d6944c7eefe3f5abe4424;hpb=4169795ad229cb8a61d71c49354be897046a8bd1;p=odoo%2Fodoo.git diff --git a/setup.py b/setup.py index 587078e..28badaf 100755 --- a/setup.py +++ b/setup.py @@ -26,20 +26,43 @@ # adapted by Nicolas Évrard # -import imp import sys import os from os.path import join, isfile, basename 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 +py2exe_keywords = {} if os.name == 'nt': import py2exe has_py2exe = True + py2exe_keywords['console'] = [ + { "script": join("bin", "openerp-server.py"), + "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))] + }] + py2exe_keywords['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", "commands", + ], + "excludes" : ["Tkconstants","Tkinter","tcl"], + } + } sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin")) @@ -51,22 +74,76 @@ if 'bdist_rpm' in sys.argv: # get python short version py_short_version = '%s.%s' % sys.version_info[:2] +# backports os.walk with followlinks from python 2.6 +def walk_followlinks(top, topdown=True, onerror=None, followlinks=False): + from os.path import join, isdir, islink + from os import listdir, error + + try: + names = listdir(top) + except error, err: + if onerror is not None: + onerror(err) + return + + dirs, nondirs = [], [] + for name in names: + if isdir(join(top, name)): + dirs.append(name) + else: + nondirs.append(name) + + if topdown: + yield top, dirs, nondirs + for name in dirs: + path = join(top, name) + if followlinks or not islink(path): + for x in walk_followlinks(path, topdown, onerror, followlinks): + yield x + if not topdown: + yield top, dirs, nondirs + +if sys.version_info < (2, 6): + os.walk = walk_followlinks + def find_addons(): for root, _, names in os.walk(join('bin', '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': - for root, _, names in os.walk(join('bin','addons')): - files.append((root, [join(root, name) for name in names])) + os.chdir('bin') + for (dp, dn, names) in os.walk('addons'): + files.append((dp, map(lambda x: join('bin', 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])) - files.append(('.', [join('bin', 'import_xml.rng'), - join('bin', 'server.pkey'), - join('bin', 'server.cert')])) + #for root, _, names in os.walk('pixmaps'): + # files.append((root, [join(root, name) for name in names])) + files.append(('.', [join('bin', 'import_xml.rng'),])) else: man_directory = join('share', 'man') files.append((join(man_directory, 'man1'), ['man/openerp-server.1'])) @@ -81,9 +158,7 @@ def data_files(): openerp_site_packages = join(get_python_lib(prefix=''), 'openerp-server') - files.append((openerp_site_packages, [join('bin', 'import_xml.rng'), - join('bin', 'server.pkey'), - join('bin', 'server.cert')])) + files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),])) if sys.version_info[0:2] == (2,5): files.append((openerp_site_packages, [ join('python25-compat','BaseHTTPServer.py'), @@ -101,6 +176,14 @@ def data_files(): 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-server': 'bin'} for mod, path in find_addons(): @@ -118,22 +201,8 @@ class openerp_server_install(install): 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","pywebdav", - ], - "excludes" : ["Tkconstants","Tkinter","tcl"], - } -} + + setup(name = name, version = version, @@ -150,55 +219,59 @@ setup(name = name, }, scripts = ['openerp-server'], packages = [ - '.'.join(['openerp-server'] + package.split('.')[1:]) for package in find_packages() + '.'.join(['openerp-server'] + package.split('.')[1:]) + for package in find_packages() ], + include_package_data = True, + package_data = { + '': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'], + }, package_dir = find_package_dirs(), - console = [ - { - "script": join("bin", "openerp-server.py"), - "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))] - } + install_requires = [ + 'lxml', + 'mako', + 'python-dateutil', + 'psycopg2', + 'pychart', + 'pydot', + 'pytz', + 'reportlab', + 'caldav', + 'pyyaml', + 'pywebdav', + 'feedparser', ], - options = options, - install_requires = ['lxml', - 'mako', - 'python-dateutil', - 'psycopg2', - 'pychart', - 'pydot', - 'pytz', - 'reportlab', - 'pyyaml', - 'pywebdav'], extras_require={ 'SSL' : ['pyopenssl'], - } + }, + **py2exe_keywords ) 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__ - zoneinfo_dir = join(os.path.dirname(pytz.__file__), 'zoneinfo') - # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib' - disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__)) - zipfile_path = join(options['py2exe']['dist_dir'], 'library.zip') - 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: - z.write(join(absdir, f), join(zip_dir, f)) - z.close() + # 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__ + zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo') + # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib' + disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__)) + zipfile_path = os.path.join(py2exe_keywords['options']['py2exe']['dist_dir'], 'library.zip') + 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: + z.write(os.path.join(absdir, f), os.path.join(zip_dir, f)) + z.close()