forked from rowinggolfer/openmolar2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·423 lines (358 loc) · 15.2 KB
/
setup.py
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###############################################################################
## ##
## Copyright 2011-2012, Neil Wallace <[email protected]> ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU 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 General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###############################################################################
from distutils.core import setup
import logging
import os
import sys
import ConfigParser
logging.basicConfig(level=logging.INFO)
DESCRIPTION = 'Dental Practice Management Software'
AUTHOR = 'Neil Wallace'
EMAIL = '[email protected]'
URL = 'http://www.openmolar.com'
LICENSE = 'GPL v3'
MAINCONF = "setup.cnf"
PARTCONF = "setup_part.cnf"
# keep a note of any setup created files which are to be removed
# I don't want any files own by root left behind.
cleanup_files = []
try:
from configure import OMConfig
CONF = MAINCONF
if not os.path.isfile(CONF):
logging.debug('%s not found..'% CONF)
print ('please run python configure.py')
sys.exit(1)
ALL_PACKAGES_AVAILABLE = True
except ImportError:
# this file works if included in an sdist package.
# however it will only install one component
logging.debug("partial setup mode")
CONF = PARTCONF
ALL_PACKAGES_AVAILABLE = False
config = ConfigParser.RawConfigParser()
config.read(CONF)
INSTALL_NAMESPACE = (config.has_section("namespace") and
config.getboolean("namespace", "include"))
INSTALL_COMMON = (config.has_section("common") and
config.getboolean("common", "include"))
INSTALL_ADMIN = (config.has_section("admin") and
config.getboolean("admin", "include"))
INSTALL_CLIENT = (config.has_section("client") and
config.getboolean("client", "include"))
INSTALL_SERVER = (config.has_section("server") and
config.getboolean("server", "include"))
INSTALL_LANG = (config.has_section("lang") and
config.getboolean("lang", "include"))
if INSTALL_SERVER and "win" in sys.platform and "install" in sys.argv:
logging.error("Server package cannot be installed on windows")
INSTALL_SERVER = False
if ALL_PACKAGES_AVAILABLE:
logging.info("including the following packages (as per setup.cnf file)")
for include, name in (
(INSTALL_NAMESPACE, "namespace"),
(INSTALL_COMMON, "common modules"),
(INSTALL_CLIENT, "client application"),
(INSTALL_ADMIN, "admin application"),
(INSTALL_SERVER, "server daemon"),
(INSTALL_LANG, "language pack")):
if include:
logging.info ("package - %s"% name)
def write_manifest_in(files=[]):
f = open("MANIFEST.in", "w")
f.write("include setup_part.cnf\n")
for file_ in files:
f.write("include %s\n"% file_)
f.close()
def get_version(name):
'''
returns a string with in the format X.Y.Z+hg03d
'''
major_version = config.get(name, "version")
try:
return "%s+hg%03d"% ( major_version,
config.getint(name, "revision_number"))
except ConfigParser.NoSectionError:
logging.warning("no hg version")
except ConfigParser.NoOptionError:
logging.warning("no hg version")
return major_version
###############################################################################
## "namespace" setup starts ##
###############################################################################
if INSTALL_NAMESPACE:
logging.info("running namespace setup")
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("namespace", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in([])
setup(
name = 'openmolar-namespace',
version = get_version("namespace"),
description = DESCRIPTION + ' - namespace',
author = AUTHOR,
author_email = EMAIL,
url = URL,
license = LICENSE,
package_dir = {'lib_openmolar' : 'src/lib_openmolar'},
packages = ['lib_openmolar'],
)
###############################################################################
## "common" setup starts ##
###############################################################################
if INSTALL_COMMON:
try:
import lib_openmolar
except ImportError:
logging.warning("please install openmolar-namespace before this package")
logging.info("running common setup")
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("common", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in(["src/main.py"])
setup(
name = 'openmolar-common',
version = get_version("common"),
description = DESCRIPTION + ' - common library',
author = AUTHOR,
author_email = EMAIL,
url = URL,
license = LICENSE,
package_dir = {'lib_openmolar' : 'src/lib_openmolar'},
packages = ['lib_openmolar.common',
'lib_openmolar.common.db_orm',
'lib_openmolar.common.connect',
'lib_openmolar.common.datatypes',
'lib_openmolar.common.import_export',
'lib_openmolar.common.qt4',
'lib_openmolar.common.qt4.dialogs',
'lib_openmolar.common.qt4.postgres',
'lib_openmolar.common.qt4.printing',
'lib_openmolar.common.qt4.widgets',
'lib_openmolar.common.qt4.plugin_tools',
],
data_files=[
('/etc/openmolar/connections-available',
['src/config_files/demo.conf']
),
('/etc/openmolar/connections230-available',
['src/config_files/localhost.conf']
),
('/usr/share/openmolar/templates',
['src/config_files/conf.sample']
),
],
)
###############################################################################
## "admin" setup starts ##
###############################################################################
if INSTALL_ADMIN:
logging.info("running admin setup")
try:
import lib_openmolar
except ImportError:
logging.warning("please install openmolar-namespace before this package")
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("admin", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in(["misc/admin/*", "man/admin/*", "src/admin.py"])
setup(
name = 'openmolar-admin',
version = get_version("admin"),
description = DESCRIPTION + ' - admin library and application',
author = AUTHOR,
author_email = EMAIL,
url = URL,
license = LICENSE,
package_dir = {'lib_openmolar' : 'src/lib_openmolar'},
packages = ['lib_openmolar.admin',
'lib_openmolar.admin.data_import',
'lib_openmolar.admin.db_orm',
'lib_openmolar.admin.db_tools',
'lib_openmolar.admin.qt4',
'lib_openmolar.admin.qt4.classes',
'lib_openmolar.admin.qt4.dialogs',
],
data_files = [
('/usr/share/icons/hicolor/scalable/apps',
['misc/admin/openmolar-admin.svg']),
('/usr/share/applications',
['misc/admin/openmolar2-admin.desktop']),
('/etc/openmolar/admin/connections',[]),
('/etc/openmolar/admin/connections230',[])
],
scripts = ['misc/admin/openmolar-admin'],
)
###############################################################################
## "client" setup starts ##
###############################################################################
if INSTALL_CLIENT:
logging.info("running client setup")
try:
import lib_openmolar
except ImportError:
logging.warning("please install openmolar-namespace before this package")
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("client", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in(["misc/client/*", "man/client/*", "src/client.py"])
setup(
name = 'openmolar-client',
version = get_version("client"),
description = DESCRIPTION + ' - client library and application',
author = AUTHOR,
author_email = EMAIL,
url = URL,
license = LICENSE,
package_dir = {'lib_openmolar' : 'src/lib_openmolar'},
packages = [
'lib_openmolar.client',
'lib_openmolar.client.classes',
'lib_openmolar.client.db_orm',
'lib_openmolar.client.db_orm.diary',
'lib_openmolar.client.db_orm.table_models',
'lib_openmolar.client.qt4',
'lib_openmolar.client.qt4.dialogs',
'lib_openmolar.client.qt4.dialogs.address_dialogs',
'lib_openmolar.client.qt4.dialogs.address_dialogs.components',
'lib_openmolar.client.qt4.diary',
'lib_openmolar.client.qt4.diary.components',
'lib_openmolar.client.qt4.diary.dialogs',
'lib_openmolar.client.qt4.patient_records',
'lib_openmolar.client.qt4.patient_records.pages',
'lib_openmolar.client.qt4.pt_diary_widget',
'lib_openmolar.client.qt4.widgets',
'lib_openmolar.client.qt4.widgets.chart_editor',
'lib_openmolar.client.qt4.widgets.chart_widgets',
'lib_openmolar.client.qt4.widgets.procedures',
],
data_files = [
('/usr/share/icons/hicolor/scalable/apps',
['misc/client/openmolar2.svg']),
('/usr/share/applications',
['misc/client/openmolar2.desktop']),
('/etc/openmolar/client/connections',[]),
('/etc/openmolar/client/connections230',[]),
],
scripts = ['misc/client/openmolar-client'],
)
###############################################################################
## "server" setup starts ##
###############################################################################
if INSTALL_SERVER:
logging.info("running server setup")
try:
import lib_openmolar
except ImportError:
logging.warning("please install openmolar-namespace before this package")
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("server", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in([
"misc/server/*",
"man/server/*",
"src/server.py",
"src/shell_scripts/*"
])
setup(
name = 'openmolar-server',
version = get_version("server"),
description = DESCRIPTION + \
' - the xml_rpc server component of openmolar2',
author = AUTHOR,
author_email = EMAIL,
url = URL,
license = LICENSE,
package_dir = {'lib_openmolar' : 'src/lib_openmolar'},
packages = ['lib_openmolar.server',
'lib_openmolar.server.servers',
'lib_openmolar.server.daemon',
'lib_openmolar.server.misc',
'lib_openmolar.server.functions'],
scripts = ['misc/server/openmolar-server',
'misc/server/openmolar-init-master-db',
'misc/server/openmolar-init-master-user',
'misc/server/openmolar-alter-master-user',
'misc/server/openmolar-fuzzymatch',],
data_files=[
('/etc/init.d', ['misc/server/openmolar']),
('/usr/share/openmolar/',
['misc/server/master_schema.sql',
'misc/server/schemas/latest_schema.sql',
'misc/server/schemas/latest_permissions.sql',
'misc/server/privatekey.pem',
'misc/server/cert.pem']),
],
)
###############################################################################
## "lang" setup starts ##
###############################################################################
if INSTALL_LANG:
logging.info("running lang setup")
logging.error( "language pack not yet available")
if ALL_PACKAGES_AVAILABLE:
new_config = OMConfig()
new_config.set("lang", "include", True)
f = open(PARTCONF, "w")
new_config.write(f)
f.close()
write_manifest_in()
###############################################################################
# and finally.. if we've got this far.. remove any unwanted cruft #
###############################################################################
logging.info("cleaning up any temporary files")
if ALL_PACKAGES_AVAILABLE:
cleanup_files.append(PARTCONF)
cleanup_files.append("MANIFEST.in")
cleanup_files.append("MANIFEST")
for file_ in cleanup_files:
try:
if os.path.isfile(file_):
os.remove(file_)
except OSError:
logging.exception("Unable to remove %s"% file_)
logging.info("ALL DONE!")
sys.exit(0)