OSDN Git Service

updated dependencies on debian
[mypaint-anime/master.git] / mypaint.in
1 # This file is part of MyPaint.
2 # Copyright (C) 2007-2009 by Martin Renold <martinxyz@gmx.ch>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 """
10 This script does all the platform dependent stuff. Its main task is
11 to figure out where the python modules are.
12 """
13
14 # This helps on slow PCs where the python overhead dominates.
15 # (30% higher framerate measured on 533MHz CPU; startup slowdown below 20%)
16 # Note: python -O -O does not help.
17 try:
18     import psyco
19     psyco.full()
20 except ImportError:
21     pass
22
23 import sys, os
24 join = os.path.join
25
26 lib_shared='share/mypaint/'
27 # note: some distros use lib64 instead, they have to edit this...
28 lib_compiled='lib/mypaint/'
29
30 scriptdir=os.path.dirname(sys.argv[0])
31
32 # this script is installed as $prefix/bin. We just need $prefix to continue.
33 #pwd=os.getcwd() # why????
34 #dir_install=os.path.normpath(join(pwd,scriptdir)) # why????
35 dir_install=scriptdir # same, except maybe if scriptdir is relative...
36
37 if os.path.basename(dir_install) == 'bin':
38     prefix=os.path.dirname(dir_install)
39     libpath=join(prefix, lib_shared)
40     libpath_compiled = join(prefix, lib_compiled)
41     sys.path.insert(0, libpath)
42     sys.path.insert(0, libpath_compiled)
43 else:
44     # we are not installed
45     prefix=None
46     libpath='.'
47     # checking for import error below
48
49 try: # just for a nice error message
50     from lib import mypaintlib
51 except ImportError:
52     print
53     print "We are not correctly installed or compiled!"
54     print 'script: "%s"' % sys.argv[0]
55     if prefix:
56         print 'deduced prefix: "%s"' % dir_install
57         print 'lib_shared: "%s"' % libpath
58         print 'lib_compiled: "%s"' % libpath_compiled
59     print
60     raise
61
62 datapath = libpath
63 if not os.path.isdir(join(datapath, 'brushes')):
64     print 'Default brush collection not found! It should have been here:'
65     print datapath
66     raise sys.exit(1)
67
68 homepath =  os.path.expanduser('~')
69 if homepath == '~':
70     confpath = join(prefix, 'UserData')
71 else:
72     confpath = join(homepath, '.mypaint/')
73
74 from gui import application
75 application.main(datapath, confpath)