~openerp-dev/openobject-client/6.1-opw-591393-xal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    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
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    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
#    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/>.
#
##############################################################################

# setup for OpenERP GTK client
#   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 sys
import os
import glob
import shutil

from setuptools import setup
from setuptools.command.install import install as suc_install
from distutils.sysconfig import get_python_lib
from mydistutils import ClientDistribution
from distutils.dir_util import copy_tree as copy

has_py2exe = False
if sys.platform == 'win32':
    import py2exe
    has_py2exe = True

#    origIsSystemDLL = py2exe.build_exe.isSystemDLL
#    def isSystemDLL(pathname):
#        if os.path.basename(pathname).lower() in ("msvcp71.dll", "mfc71.dll"):
#                return 0
#        return origIsSystemDLL(pathname)
#    py2exe.build_exe.isSystemDLL = isSystemDLL

sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin"))

opj = os.path.join

execfile(opj('bin', 'release.py'))

if len(sys.argv) > 1 and sys.argv[1] == 'bdist_rpm':
    version = version.split('-')[0]

# get python short version
py_short_version = '%s.%s' % sys.version_info[:2]

def data_files():
    '''Build list of data files to be installed'''
    files = []
    if sys.platform == 'win32':
        import matplotlib
        datafiles = matplotlib.get_py2exe_datafiles()
        if isinstance(datafiles, list):
            files.extend(datafiles)
        else:
            files.append(datafiles)
        os.chdir('bin')
        for (dp, dn, names) in os.walk('share\\locale'):
            files.append((dp, map(lambda x: opj('bin', dp, x), names)))
        os.chdir('..')
        files.append((".",["bin\\openerp.ui", "bin\\win_error.ui", 'bin\\tipoftheday.txt', 'doc\\README.txt']))
        files.append(("pixmaps", glob.glob("bin\\pixmaps\\*.*")))
        files.append(("po", glob.glob("bin\\po\\*.*")))
        files.append(("icons", glob.glob("bin\\icons\\*.png")))
        files.append(("share\\locale", glob.glob("bin\\share\\locale\\*.*")))

    else:
        files.append((opj('share','man','man1',''),['man/openerp-client.1']))
        files.append((opj('share','doc', 'openerp-client-%s' % version), [f for
            f in glob.glob('doc/*') if os.path.isfile(f)]))
        files.append((opj('share', 'pixmaps', 'openerp-client'),
            glob.glob('bin/pixmaps/*.png')))
        files.append((opj('share', 'pixmaps', 'openerp-client', 'icons'),
            glob.glob('bin/icons/*.png')))
        files.append((opj('share', 'openerp-client'), ['bin/openerp.ui', 'bin/tipoftheday.txt',
                                                       'bin/win_error.ui']))
    return files

included_plugins = ['workflow_print']

def find_plugins():
    for plugin in included_plugins:
        path=opj('bin', 'plugins', plugin)
        for dirpath, dirnames, filenames in os.walk(path):
            if '__init__.py' in filenames:
                modname = dirpath.replace(os.path.sep, '.')
                yield modname.replace('bin', 'openerp-client', 1)

def translations():
    trans = []
    dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
    for po in glob.glob('bin/po/*.po'):
        lang = os.path.splitext(os.path.basename(po))[0]
        trans.append((dest % (lang, name), po))
    return trans

if sys.platform != 'win32' and 'build_po' in sys.argv:
    os.system('(cd bin ; find . -name \*.ui | xargs -L 1 intltool-extract --type=gettext/glade)')
    os.system('(cd bin ; find . -name \*.py && find . -name \*.ui.h | xargs xgettext --from-code=UTF-8 -o po/%s.pot)' % name)
    for file in ([ os.path.join('bin', 'po', fname) for fname in os.listdir('bin/po') ]):
        if os.path.isfile(file):
            os.system('msgmerge --update --backup=off %s bin/po/%s.pot' % (file, name))
    sys.exit()

options = {
    "py2exe": {
        "compressed": 1,
        "optimize": 1,
        "dist_dir": 'dist',
        "bundle_files": 3,
        "packages": [
           "encodings","gtk","gtk.glade","gio", "glib", "matplotlib", "pytz", "OpenSSL",
            "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
            "lxml.objectify", "decimal"
        ],
        "excludes": ["Tkinter", "tcl", "TKconstants"],
        "dll_excludes": ["MSVCP90.dll","tcl85.dll","tk85.dll"],

    }
}

complementary_arguments = dict()

if sys.platform == 'win32':
    complementary_arguments['windows'] = [
        {
            'script' : os.path.join('bin', 'openerp-client.py'),
            'icon_resources' : [(1, os.path.join('bin', 'pixmaps', 'openerp-icon.ico'))],
            'install_requires': [ 'PyGTK', ],
        }
    ]
else:
    complementary_arguments['scripts'] = ['openerp-client']
    complementary_arguments['distclass'] = ClientDistribution


suc_install.sub_commands.append(('install_mo',  None))

setup(name             = name,
      version          = version,
      description      = description,
      long_description = long_desc,
      url              = url,
      author           = author,
      author_email     = author_email,
      classifiers      = filter(None, classifiers.splitlines()),
      license          = license,
      data_files       = data_files(),
      translations     = translations(),
      packages         = ['openerp-client',
                          'openerp-client.common',
                          'openerp-client.modules',
                          'openerp-client.modules.action',
                          'openerp-client.modules.gui',
                          'openerp-client.modules.gui.window',
                          'openerp-client.modules.gui.window.view_sel',
                          'openerp-client.modules.gui.window.view_tree',
                          'openerp-client.modules.spool',
                          'openerp-client.printer',
                          'openerp-client.tools',
                          'openerp-client.tinygraph',
                          'openerp-client.widget',
                          'openerp-client.widget.model',
                          'openerp-client.widget.screen',
                          'openerp-client.widget.view',
                          'openerp-client.widget.view.form_gtk',
                          'openerp-client.widget.view.tree_gtk',
                          'openerp-client.widget.view.graph_gtk',
                          'openerp-client.widget.view.calendar_gtk',
                          'openerp-client.widget.view.diagram_gtk',
                          'openerp-client.widget_search',
                          'openerp-client.SpiffGtkWidgets',
                          'openerp-client.SpiffGtkWidgets.Calendar',
                          'openerp-client.plugins'] + list(find_plugins()),
      package_dir      = {'openerp-client': 'bin'},
      options = options,
      install_requires = [
          'lxml',
          'pytz',
          'python-dateutil',
      ],
      **complementary_arguments
)

if has_py2exe:
    dist = opj(os.getcwd() , options['py2exe']['dist_dir'])
    if os.getenv('gtk_runtime'):
        gtk_runtime=os.getenv('gtk_runtime')
        # To enable gtk theme we need to add below dir of gtkruntime to dist dir
        add_dir = ["share\\locale", "share\\themes", "lib\\gtk-2.0", "etc"]
        for dir in add_dir:
            copy(opj(gtk_runtime, dir), opj(dist, dir))
    else:
        print >> sys.stderr, 'Error: Environment variable GTK_RUNTIME is not set'
    if os.getenv('openerp_dlls'):
        openerp_dlls = os.getenv('openerp_dlls')
        copy(opj(openerp_dlls, 'add_to_dist'), dist)
    else:
        print >> sys.stderr, 'Error: Environment variable openerp_dlls is not set'
#
    # 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(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()

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: