forked from charrea6/freevo1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
174 lines (146 loc) · 5.94 KB
/
setup.py
File metadata and controls
174 lines (146 loc) · 5.94 KB
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
#!/usr/bin/env python
"""Setup script for the freevo distribution."""
__revision__ = "$Id$"
# Python distutils stuff
import os
import sys
# Freevo distutils stuff
sys.path.append('./src')
import version
from util.distribution import setup, Extension, check_libs, docbook_finder
from distutils import core
libs_to_check = [
('kaa', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
('kaa.metadata', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
('kaa.imlib2', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
('BeautifulSoup', 'http://www.crummy.com/software/BeautifulSoup/' ),
('pygame', 'http://www.pygame.org'),
('Image', 'http://www.pythonware.com/products/pil/'),
('twisted', 'http://www.twistedmatrix.com/'),
('zope.interface', 'http://www.zope.org/Products/ZopeInterface'),
('twisted.web.microdom', 'http://www.twistedmatrix.com/'),
#('Numeric', 'http://numeric.scipy.org/'),
]
if sys.hexversion < 0x2050000:
libs_to_check.append(('elementtree', 'http://effbot.org/zone/elementtree.htm'))
check_libs(libs_to_check)
class Runtime(core.Command):
description = "download and install runtime"
user_options = []
boolean_options = []
help_options = []
negative_opt = {}
def initialize_options (self):
pass
def finalize_options (self):
pass
def download(self, package):
"""
download a package from sourceforge
"""
url = 'http://osdn.dl.sourceforge.net/sourceforge/' + package
file = package[package.rfind('/')+1:]
ddir = os.path.join(os.environ['HOME'], '.freevo/dist')
if not os.path.isdir(ddir):
os.makedirs(ddir)
full = os.path.join(ddir, file)
if not os.path.isfile(full):
print 'Downloading %s' % file
os.system('wget %s -O %s' % (url, full))
if not os.path.isfile(full):
print
print 'Failed to download %s' % file
print
print 'Please download %s from http://www.sf.net/projects/%s' % \
(file, package[:package.find('/')])
print 'and store it as %s' % full
print
sys.exit(0)
return full
def mmpython_install(self, result, dirname, names):
"""
install mmpython into the runtime
"""
for n in names:
source = os.path.join(dirname, n)
if dirname.find('/') > 0:
destdir = dirname[dirname.find('/')+1:]
else:
destdir = ''
dest = os.path.join('runtime/lib/python2.3/site-packages',
'mmpython', destdir, n)
if os.path.isdir(source) and not os.path.isdir(dest):
os.mkdir(dest)
if n.endswith('.py') or n == 'mminfo':
if n == 'dvdinfo.py':
# runtime contains a bad hack version of dvdinfo
# the normal one doesn't work
continue
os.system('mv "%s" "%s"' % (source, dest))
def run (self):
"""
download and install the runtime + current mmpython
"""
mmpython = self.download('mmpython/mmpython-%s.tar.gz' % version.mmpython)
runtime = self.download('freevo/freevo-runtime-%s.tar.gz' % version.runtime)
print 'Removing runtime directory'
os.system('rm -rf runtime')
print 'Unpacking runtime'
os.system('tar -zxf %s' % runtime)
print 'Unpacking mmpython'
os.system('tar -zxf %s' % mmpython)
print 'Installing mmpython into runtime'
os.path.walk('mmpython-%s' % version.mmpython, self.mmpython_install, None)
os.system('rm -rf mmpython-%s' % version.mmpython)
# check if everything is in place
if (len(sys.argv) < 2 or sys.argv[1].lower() not in ('i18n', '--help', '--help-commands')):
if os.path.isdir('.svn'):
try:
from subprocess import Popen, PIPE
os.environ['LC_ALL']='C'
p1 = Popen(["svn", "info", "--revision=BASE"], stdout=PIPE, env=os.environ)
p2 = Popen(["sed", "-n", "/Revision:/s/Revision: *\([0-9]*\)/\\1/p"], stdin=p1.stdout, stdout=PIPE)
revision = p2.communicate()[0]
fh = open('src/revision.py', 'w')
try:
fh.write('"""\n')
fh.write('Freevo revision number\n')
fh.write('"""\n')
fh.write('\n')
fh.write('__revision__ = \'%s\'\n' % revision.strip('\n'))
finally:
fh.close()
except Exception, e:
print e
if (not os.path.isdir('./Docs/installation/html')):
print 'Docs/howto not found. Please run ./autogen.sh'
sys.exit(0)
import revision
# only add files not in share and src
data_files = []
# add some files to Docs
for f in ('COPYING', 'RELEASE_NOTES', 'ChangeLog', 'INSTALL', 'README'):
data_files.append(('share/doc/freevo-%s' % version.__version__, ['%s' % f ]))
data_files.append(('share/doc/freevo-%s' % version.__version__, ['Docs/CREDITS' ]))
#data_files.append(('share/fxd', ['share/fxd/webradio.fxd']))
# copy freevo_config.py to share/freevo. It's the best place to put it
# for now, but the location should be changed
data_files.append(('share/freevo', [ 'freevo_config.py' ]))
# add docbook style howtos
os.path.walk('./Docs/installation', docbook_finder, data_files)
os.path.walk('./Docs/plugin_writing', docbook_finder, data_files)
# start script
scripts = ['freevo']
# now start the python magic
setup (name = "freevo",
version = version.__version__,
description = "Freevo",
author = "Krister Lagerstrom, et al.",
author_email = "freevo-devel@lists.sourceforge.net",
url = "http://www.freevo.org",
license = "GPL",
i18n = 'freevo',
scripts = scripts,
data_files = data_files,
cmdclass = { 'runtime': Runtime }
)