[FIX] tour.js: tour shop
[odoo/odoo.git] / setup.py
old mode 100755 (executable)
new mode 100644 (file)
index 4822de9..041a8df
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 ##############################################################################
-#    
+#
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
 #    GNU Affero General Public License for more details.
 #
 #    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
-# 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 glob, os, re, setuptools, sys
+from os.path import join
 
-import imp
-import sys
-import os
-from os.path import join, isfile
-import glob
+# List all data files
+def data():
+    r = {}
+    for root, dirnames, filenames in os.walk('openerp'):
+        for filename in filenames:
+            if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename):
+                r.setdefault(root, []).append(os.path.join(root, filename))
 
-from distutils.core import setup, Command
-from distutils.command.install import install
+    if os.name == 'nt':
+        r["Microsoft.VC90.CRT"] = glob.glob('C:\Microsoft.VC90.CRT\*.*')
+
+        import babel
+        # Add data, but also some .py files py2exe won't include automatically.
+        # TODO This should probably go under `packages`, instead of `data`,
+        # but this will work fine (especially since we don't use the ZIP file
+        # approach).
+        r["babel/localedata"] = glob.glob(os.path.join(os.path.dirname(babel.__file__), "localedata", '*'))
+        others = ['global.dat', 'numbers.py', 'support.py', 'plural.py']
+        r["babel"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), f), others)
+        others = ['frontend.py', 'mofile.py']
+        r["babel/messages"] = map(lambda f: os.path.join(os.path.dirname(babel.__file__), "messages", f), others)
+
+        import pytz
+        tzdir = os.path.dirname(pytz.__file__)
+        for root, _, filenames in os.walk(os.path.join(tzdir, "zoneinfo")):
+            base = os.path.join('pytz', root[len(tzdir) + 1:])
+            r[base] = [os.path.join(root, f) for f in filenames]
+
+        import docutils
+        dudir = os.path.dirname(docutils.__file__)
+        for root, _, filenames in os.walk(dudir):
+            base = os.path.join('docutils', root[len(dudir) + 1:])
+            r[base] = [os.path.join(root, f) for f in filenames if not f.endswith(('.py', '.pyc', '.pyo'))]
+
+    return r.items()
+
+def gen_manifest():
+    file_list="\n".join(data())
+    open('MANIFEST','w').write(file_list)
 
-has_py2exe = False
 if os.name == 'nt':
-    import py2exe
-    has_py2exe = True
-
-sys.path.append(join(os.path.abspath(os.path.dirname(__file__)), "bin"))
-
-execfile(join('bin', 'release.py'))
-
-if sys.argv[1] == 'bdist_rpm':
-    version = version.split('-')[0]
+    sys.path.append("C:\Microsoft.VC90.CRT")
 
-# get python short version
-py_short_version = '%s.%s' % sys.version_info[:2]
-
-required_modules = [
-    ('lxml', 'lxml module: pythonic libxml2 and libxslt bindings'),
-    ('mx', "egenix's mx library for its extended DateTime module"),
-    ('psycopg2', 'PostgreSQL module'),
-    ('pychart', 'pychart module'),
-    ('pydot', 'pydot module'),
-    ('pytz', 'Timezone handling library for Python'),
-    ('reportlab', 'reportlab module'),
-]
-
-def check_modules():
-    errors = []
-    for modname, desc in required_modules:
-        try:
-            imp.find_module(modname)
-        except ImportError:
-            errors.append(
-                'Error: python module %s (%s) is required' % (modname, desc))
-
-    if errors:
-        print '\n'.join(errors)
-        sys.exit(1)
-
-def find_addons():
-    for (dp, dn, names) in os.walk(join('bin', 'addons')):
-        if '__terp__.py' in names:
-            modname = os.path.basename(dp)
-            yield (modname, dp)
-    #look for extra modules
-    try:
-        empath = os.getenv('EXTRA_MODULES_PATH','../addons/')
-        f = open(join(empath,'server_modules.list'),'r')
-        # print 'Getting modules from:' , join(empath,'server_modules.list')
-        mods = f.readlines()
-        for mname in mods:
-            mname = mname.strip()
-            if not mname:
-                continue
-            if os.path.exists(join(empath,mname,'__terp__.py')):
-                yield ( mname, join(empath,mname) )
-            else:
-                print "Module %s specified, but no valid path." % mname
-    except:
-        pass
-
-def data_files():
-    '''Build list of data files to be installed'''
-    files = []
+def py2exe_options():
     if os.name == 'nt':
-        for (dp,dn,names) in os.walk(join('bin','addons')):
-            files.append((dp, map(lambda x: join(dp, x), names)))
-        for (dp,dn,names) in os.walk('doc'):
-            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')]))
+        import py2exe
+        return {
+            "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], },
+                          { "script": "openerp-gevent" },
+                          { "script": "odoo.py" },
+            ],
+            'options' : {
+                "py2exe": {
+                    "skip_archive": 1,
+                    "optimize": 0, # keep the assert running, because the integrated tests rely on them.
+                    "dist_dir": 'dist',
+                    "packages": [
+                        "HTMLParser",
+                        "PIL",
+                        "asynchat", "asyncore",
+                        "commands",
+                        "dateutil",
+                        "decimal",
+                        "docutils",
+                        "email",
+                        "encodings",
+                        "imaplib",
+                        "jinja2",
+                        "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify",
+                        "mako",
+                        "markupsafe",   # dependence of jinja2 and mako
+                        "mock",
+                        "openerp",
+                        "passlib",
+                        "poplib",
+                        "psutil",
+                        "pychart",
+                        "pydot",
+                        "pyparsing",
+                        "pytz",
+                        "reportlab",
+                        "requests",
+                        "select",
+                        "simplejson",
+                        "smtplib",
+                        "uuid",
+                        "vatnumber",
+                        "vobject",
+                        "win32service", "win32serviceutil",
+                        "xlwt",
+                        "xml", "xml.dom",
+                        "yaml",
+                    ],
+                    "excludes" : ["Tkconstants","Tkinter","tcl"],
+                }
+            }
+        }
     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']))
-
-        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/*'))))
+        return {}
 
-        openerp_site_packages = join('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server')
+execfile(join(os.path.dirname(__file__), 'openerp', 'release.py'))
 
-        files.append((openerp_site_packages, [join('bin', 'import_xml.rng'),
-                                              join('bin', 'server.pkey'),
-                                              join('bin', 'server.cert')]))
-
-        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('lib', 'python%s' % py_short_version, 'site-packages', 'openerp-server','addons', addonname)
-            pathfiles = []
-            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), '.')))
-                    pathfiles.extend(((res, map(lambda fil: join(root, fil), innerfiles)),))
-            files.extend(pathfiles)
-
-    # for tup in files:
-    #    print "Files:", tup[0], tup[1]
-    return files
-
-if not os.getenv('NO_CHECK_MODULES',False) :
-    check_modules()
-
-f = file('openerp-server','w')
-start_script = """#!/bin/sh\necho "OpenERP Setup - The content of this file is generated at the install stage\n" """
-f.write(start_script)
-f.close()
-
-def find_package_dirs():
-    res = {}
-    for (mod, path) in find_addons():
-        res ['openerp-server.addons.'+ mod ] = path
-    res ['openerp-server'] = 'bin'
-    return res
-
-class openerp_server_install(install):
-    def run(self):
-        # create startup script
-        start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-server.py $@\n" % (join(self.install_libbase, "openerp-server"), 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.dom", "xml.xpath",
-                     "encodings","mx.DateTime","wizard","pychart","PIL", "pyparsing",
-                     "pydot","asyncore","asynchat", "reportlab", "vobject",
-                     "HTMLParser", "select"],
-        "excludes" : ["Tkconstants","Tkinter","tcl"],
-    }
-}
+# Notes for OpenERP developer on windows:
+#
+# To setup a windows developer evironement install python2.7 then pip and use
+# "pip install <depencey>" for every dependency listed below.
+#
+# Dependecies that requires DLLs are not installable with pip install, for
+# them we added comments with links where you can find the installers.
+#
+# OpenERP on windows also require the pywin32, the binary can be found at
+# http://pywin32.sf.net
+#
+# Both python2.7 32bits and 64bits are known to work.
 
-setup(name             = name,
+setuptools.setup(
+      name             = 'openerp',
       version          = version,
       description      = description,
       long_description = long_desc,
@@ -191,61 +147,52 @@ setup(name             = name,
       author_email     = author_email,
       classifiers      = filter(None, classifiers.split("\n")),
       license          = license,
-      data_files       = data_files(),
-      cmdclass         = {
-            'install' : openerp_server_install,
+      scripts          = ['openerp-server', 'openerp-gevent', 'odoo.py'],
+      data_files       = data(),
+      packages         = setuptools.find_packages(),
+      dependency_links = ['http://download.gna.org/pychart/'],
+      #include_package_data = True,
+      install_requires = [
+          'pychart', # not on pypi, use: pip install http://download.gna.org/pychart/PyChart-1.39.tar.gz
+          'babel >= 1.0',
+          'docutils',
+          'feedparser',
+          'gdata',
+          'gevent',
+          'psycogreen',
+          'Jinja2',
+          'lxml', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
+          'mako',
+          'mock',
+          'passlib',
+          'pillow', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
+          'psutil', # windows binary code.google.com/p/psutil/downloads/list
+          'psycopg2 >= 2.2',
+          'pydot',
+          'pyparsing < 2',
+          'pyserial',
+          'python-dateutil < 2',
+          'python-ldap', # optional
+          'python-openid',
+          'pytz',
+          'pyusb >= 1.0.0b1',
+          'pyyaml',
+          'qrcode',
+          'reportlab', # windows binary pypi.python.org/pypi/reportlab
+          'requests',
+          'simplejson',
+          'unittest2',
+          'vatnumber',
+          'vobject',
+          'werkzeug',
+          'xlwt',
+      ],
+      extras_require = {
+          'SSL' : ['pyopenssl'],
       },
-      scripts          = ['openerp-server'],
-      packages         = ['openerp-server',
-                          'openerp-server.addons',
-                          'openerp-server.ir',
-                          'openerp-server.mako',
-                          'openerp-server.osv',
-                          'openerp-server.pychart',
-                          'openerp-server.report',
-                          'openerp-server.report.printscreen',
-                          'openerp-server.report.pyPdf',
-                          'openerp-server.report.render',
-                          'openerp-server.report.render.html2html',
-                          'openerp-server.report.render.makohtml2html',
-                          'openerp-server.report.render.odt2odt',
-                          'openerp-server.report.render.rml2html',
-                          'openerp-server.report.render.rml2pdf',
-                          'openerp-server.report.render.rml2txt',
-                          'openerp-server.service',
-                          'openerp-server.tools',
-                          'openerp-server.wizard',
-                          'openerp-server.workflow'] + \
-                          list(map( lambda (a, p): 'openerp-server.addons.'+ a ,find_addons())),
-      package_dir      = find_package_dirs(),
-      console = [ { "script" : "bin\\openerp-server.py", "icon_resources" : [ (1,"pixmaps\\openerp-icon.ico") ] } ],
-      options = options,
-      )
+      tests_require = ['unittest2', 'mock'],
+      **py2exe_options()
+)
 
-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()
 
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: