forked from sugarlabs/turtleart-activity
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
executable file
·93 lines (75 loc) · 3.13 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
#!/usr/bin/env python
import sys
def get_files(path):
files = []
for name in path:
files.append(os.path.join(path, name))
return files
if len(sys.argv) > 1 and '--no-sugar' == sys.argv[1]:
# Remove the argument from the stack so we don't cause problems
# for distutils
sys.argv.pop(1)
import os
import shutil
import subprocess
from distutils.core import setup
from distutils.command.install import install
class post_install(install):
def run(self):
install.run(self)
print "Running post_install"
# Create a simple module that allows the app where to discover
# its lib and share content.
dst = os.path.join(self.install_purelib, "TurtleArt")
fd = open(os.path.join(dst, "installinfo.py"), "w")
fd.write("INSTALL_PREFIX='%s'\n" % self.prefix)
fd.close()
# distutils doesn't offer a nice way to do recursive install of
# a directory tree, so we install the remaining parts here.
libdir = os.path.join(self.root + self.install_base, "lib",
"TurtleBlocks")
if not os.path.isdir(libdir):
os.makedirs(libdir)
sharedir = os.path.join(self.root + self.install_base, "share",
"TurtleBlocks")
if not os.path.isdir(sharedir):
os.makedirs(sharedir)
shutil.copytree("plugins", os.path.join(libdir, "plugins"))
shutil.copytree("samples", os.path.join(sharedir, "samples"))
localedir = os.path.join(self.root + self.install_base, "share",
"locale")
for f in os.listdir('po'):
if not f.endswith('.po') or f == 'pseudo.po':
continue
file_name = os.path.join('po', f)
lang = f[:-3]
mo_path = os.path.join(localedir, lang, 'LC_MESSAGES')
if not os.path.isdir(mo_path):
os.makedirs(mo_path)
mo_file = os.path.join(
mo_path, 'org.laptop.TurtleArtActivity.mo')
retcode = subprocess.call(
['msgfmt', '--output-file=%s' % mo_file, file_name])
if retcode:
print ('ERROR - msgfmt failed with return code %i.'
% retcode)
DATA_FILES = [
('activity', get_files('activity/')),
('icons', get_files('icons/')),
('images', get_files('images/')),
('/usr/share/applications', ['turtleblocks.desktop'])
]
setup(name='Turtle Art',
description="A LOGO-like tool for teaching programming",
author="Walter Bender",
author_email="[email protected]",
version='0.9.4',
packages=['TurtleArt', 'TurtleArt.util'],
scripts=['turtleblocks'],
data_files=DATA_FILES,
cmdclass={"install": post_install}
)
else:
from sugar3.activity import bundlebuilder
if __name__ == "__main__":
bundlebuilder.start()