~openobject-client-kde/openobject-client-kde/trunk

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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# setup for Koo (taken from 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 imp
import sys
import os
import glob

from stat import ST_MODE

from distutils.file_util import copy_file
from distutils.sysconfig import get_python_lib
from distutils.core import setup

try:
  import py2exe

  # Override the function in py2exe to determine if a dll should be included
  dllList = ('mfc90.dll','msvcp90.dll')
  origIsSystemDLL = py2exe.build_exe.isSystemDLL
  def isSystemDLL(pathname):
    if os.path.basename(pathname).lower() in dllList:
      return 0
    return origIsSystemDLL(pathname)
  py2exe.build_exe.isSystemDLL = isSystemDLL
  
  using_py2exe = True
except:
  using_py2exe = False
  pass

opj = os.path.join

name = 'koo'
version = '1.0.0-beta2'

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

required_modules = [
	('PyQt4.QtCore', 'Qt4 Core python bindings'),
	('PyQt4.QtGui', 'Qt4 Gui python bindings'),
	('PyQt4.uic', 'Qt4 uic python bindings'),
	('PyQt4.QtWebKit', 'Qt4 WebKit python bindings')
]

def check_modules():
	ok = True
	for modname, desc in required_modules:
		try:
			exec('import %s' % modname)
		except ImportError:
			ok = False
			print 'Error: python module %s (%s) is required' % (modname, desc)

	if not ok:
		sys.exit(1)

def data_files():
	'''Build list of data files to be installed'''
	files = [
		(opj('share','man','man1',''),[ opj('man','koo.1')]),
		(opj('share', 'doc', 'koo', 'manual' ), [f for f in glob.glob(opj('doc','html','*')) if os.path.isfile(f)]),
		(opj('share', 'doc', 'koo', 'api' ), [f for f in glob.glob(opj('doc','doxygen','html','*')) if os.path.isfile(f)]),
		(opj('share', 'Koo'), [ opj('Koo','kootips.txt')]),
		(opj('share', 'Koo', 'ui'), glob.glob( opj('Koo','ui','*.ui') ) ),
		(opj('share', 'Koo', 'l10n'), glob.glob( opj('Koo','l10n','*.qm')) )
	]
	if using_py2exe:
		#trans = []
		dest = opj('share','locale','%s','LC_MESSAGES')
		#src = opj('Koo','l10n','%s','LC_MESSAGES','%s.mo')
		#for po in glob.glob( opj('Koo','l10n','*.po') ):
		    #lang = os.path.splitext(os.path.basename(po))[0]
		    #files.append( (dest % (lang, name), src % (lang, name) ) )
		    #print "ADDING: ", ( dest % (lang, name), src % (lang, name) )
		for src in glob.glob( opj('Koo','l10n','*','LC_MESSAGES','koo.mo') ):
			lang = src.split(os.sep)[2]
			files.append( ( (dest % lang), [src] ) )
	return files

def findPlugins( module ):
	result = []
	plugins = [x for x in glob.glob( opj('Koo', module,'*') ) if os.path.isdir(x)]
	for plugin in plugins:
		for dirpath, dirnames, filenames in os.walk(plugin):
			if '__init__.py' in filenames:
				result.append( dirpath.replace(os.path.sep, '.') )
	return result

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




long_desc = '''\
=====================================
Koo Client and Development Platform
=====================================

Koo is a Qt/KDE based client for Open ERP, a complete ERP and CRM. Koo 
aims for great flexibility allowing easy creation of plugins and views, high
integration with KDE4 under Unix, Windows and Mac, as well as providing
a development platform for new applications using the Open ERP server.

A set of server side modules is also provided among the Koo distribution
which provide better attachments handling and full text search capabilities.
'''

classifiers = """\
Development Status :: 4 - Beta
License :: OSI Approved :: GNU General Public License (GPL)
Programming Language :: Python
Topic :: Desktop Environment :: K Desktop Environment (KDE)
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: MacOS
Topic :: Office/Business
"""

check_modules()

# create startup script
start_script = """
cd %s/Koo
exec %s ./koo.py $@
""" % ( get_python_lib(), sys.executable)
# write script
f = open('koo.py', 'w')
f.write(start_script)
f.close()

# todo: use 
command = sys.argv[1]

packages = [
	'Koo', 
	'Koo.Actions', 
	'Koo.Common', 
	'Koo.Dialogs',
	'Koo.KooChart',
	'Koo.Model',
	'Koo.Plugins',
	'Koo.Printer',
	'Koo.Rpc',
	'Koo.Screen',
	'Koo.Search',
	'Koo.View',
	'Koo.Fields',
        ] + findPlugins('Plugins') + findPlugins('View') + findPlugins('Fields')

setup(name             = name,
      version          = version,
      description      = "Koo Client",
      long_description = long_desc,
      url              = 'http://sf.net/projects/ktiny',
      author           = 'NaN',
      author_email     = 'info@nan-tic.com',
      classifiers      = filter(None, classifiers.splitlines()),
      license          = 'GPL',
      data_files       = data_files(),
      translations     = translations(),
      pot_file         = opj('Koo','l10n','koo.pot'),
      scripts          = ['koo.py'],
      windows          = [{'script': opj('Koo','koo.py')}],
      #console          = ['Koo/koo.py'],
      packages         = packages ,
      package_dir      = {'Koo': 'Koo'},
      provides         = [ 'Koo' ],
      options          = { 'py2exe': {
                                'includes': ['sip', 'PyQt4.QtNetwork',
					'PyQt4.QtWebKit'] + packages 
                                }
                         }
      )