root/freevo/setup.py

Revision 1888, 5.9 kB (checked in by duncan, 8 weeks ago)

Small bug fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/env python
2
3"""Setup script for the freevo distribution."""
4
5
6__revision__ = "$Id$"
7
8# Python distutils stuff
9import os
10import sys
11
12# Freevo distutils stuff
13sys.path.append('./src')
14import version
15from util.distribution import setup, Extension, check_libs, docbook_finder
16from distutils import core
17
18
19libs_to_check = [
20    ('xml.utils.qp_xml', 'http://pyxml.sourceforge.net/'),
21    ('kaa', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
22    ('kaa.metadata', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
23    ('kaa.imlib2', '\"svn co svn://svn.freevo.org/kaa/trunk/ kaa\"' ),
24    ('BeautifulSoup', 'http://www.crummy.com/software/BeautifulSoup/' ),
25    ('pygame', 'http://www.pygame.org'),
26    ('Image', 'http://www.pythonware.com/products/pil/'),
27    ('twisted', 'http://www.twistedmatrix.com/'),
28    ('twisted.web.microdom', 'http://www.twistedmatrix.com/'),
29    ('Numeric', 'http://numeric.scipy.org/'),
30]
31
32if sys.hexversion < 0x2050000:
33    libs_to_check.append(('elementtree', 'http://effbot.org/zone/elementtree.htm'))
34
35check_libs(libs_to_check)
36
37
38class Runtime(core.Command):
39
40    description     = "download and install runtime"
41    user_options    = []
42    boolean_options = []
43    help_options    = []
44    negative_opt    = {}
45
46    def initialize_options (self):
47        pass
48
49    def finalize_options (self):
50        pass
51
52    def download(self, package):
53        """
54        download a package from sourceforge
55        """
56        url  = 'http://osdn.dl.sourceforge.net/sourceforge/' + package
57        file = package[package.rfind('/')+1:]
58        ddir = os.path.join(os.environ['HOME'], '.freevo/dist')
59        if not os.path.isdir(ddir):
60            os.makedirs(ddir)
61        full = os.path.join(ddir, file)
62        if not os.path.isfile(full):
63            print 'Downloading %s' % file
64            os.system('wget %s -O %s' % (url, full))
65        if not os.path.isfile(full):
66            print
67            print 'Failed to download %s' % file
68            print
69            print 'Please download %s from http://www.sf.net/projects/%s' % \
70                  (file, package[:package.find('/')])
71            print 'and store it as %s' % full
72            print
73            sys.exit(0)
74        return full
75
76
77    def mmpython_install(self, result, dirname, names):
78        """
79        install mmpython into the runtime
80        """
81        for n in names:
82            source = os.path.join(dirname, n)
83            if dirname.find('/') > 0:
84                destdir = dirname[dirname.find('/')+1:]
85            else:
86                destdir = ''
87            dest   = os.path.join('runtime/lib/python2.3/site-packages',
88                                  'mmpython', destdir, n)
89            if os.path.isdir(source) and not os.path.isdir(dest):
90                os.mkdir(dest)
91            if n.endswith('.py') or n == 'mminfo':
92                if n == 'dvdinfo.py':
93                    # runtime contains a bad hack version of dvdinfo
94                    # the normal one doesn't work
95                    continue
96                os.system('mv "%s" "%s"' % (source, dest))
97
98    def run (self):
99        """
100        download and install the runtime + current mmpython
101        """
102        mmpython = self.download('mmpython/mmpython-%s.tar.gz' % version.mmpython)
103        runtime  = self.download('freevo/freevo-runtime-%s.tar.gz' % version.runtime)
104        print 'Removing runtime directory'
105        os.system('rm -rf runtime')
106        print 'Unpacking runtime'
107        os.system('tar -zxf %s' % runtime)
108        print 'Unpacking mmpython'
109        os.system('tar -zxf %s' % mmpython)
110        print 'Installing mmpython into runtime'
111        os.path.walk('mmpython-%s' % version.mmpython, self.mmpython_install, None)
112        os.system('rm -rf mmpython-%s' % version.mmpython)
113
114
115# check if everything is in place
116if (len(sys.argv) < 2 or sys.argv[1].lower() not in ('i18n', '--help', '--help-commands')):
117    if os.path.isdir('.svn'):
118        try:
119            from subprocess import Popen, PIPE
120            os.environ['LC_ALL']='C'
121            p1 = Popen(["svn", "info", "--revision=BASE"], stdout=PIPE, env=os.environ)
122            p2 = Popen(["sed", "-n", "/Revision:/s/Revision: *\([0-9]*\)/\\1/p"], stdin=p1.stdout, stdout=PIPE)
123            revision = p2.communicate()[0]
124            fh = open('src/revision.py', 'w')
125            try:
126                fh.write('"""\n')
127                fh.write('Freevo revision number\n')
128                fh.write('"""\n')
129                fh.write('\n')
130                fh.write('__revision__ = \'%s\'\n' % revision.strip('\n'))
131            finally:
132                fh.close()
133        except Exception, e:
134            print e
135
136    if (not os.path.isdir('./Docs/installation/html')):
137        print 'Docs/howto not found. Please run ./autogen.sh'
138        sys.exit(0)
139
140import revision
141# only add files not in share and src
142
143data_files = []
144# add some files to Docs
145for f in ('COPYING', 'RELEASE_NOTES', 'ChangeLog', 'INSTALL', 'README'):
146    data_files.append(('share/doc/freevo-%s' % version.__version__, ['%s' % f ]))
147data_files.append(('share/doc/freevo-%s' % version.__version__, ['Docs/CREDITS' ]))
148#data_files.append(('share/fxd', ['share/fxd/webradio.fxd']))
149
150# copy freevo_config.py to share/freevo. It's the best place to put it
151# for now, but the location should be changed
152data_files.append(('share/freevo', [ 'freevo_config.py' ]))
153
154# add docbook style howtos
155os.path.walk('./Docs/installation', docbook_finder, data_files)
156os.path.walk('./Docs/plugin_writing', docbook_finder, data_files)
157
158# start script
159scripts = ['freevo']
160
161# now start the python magic
162setup (name         = "freevo",
163       version      = version.__version__,
164       description  = "Freevo",
165       author       = "Krister Lagerstrom, et al.",
166       author_email = "freevo-devel@lists.sourceforge.net",
167       url          = "http://www.freevo.org",
168       license      = "GPL",
169
170       i18n         = 'freevo',
171       scripts      = scripts,
172       data_files   = data_files,
173       cmdclass     = { 'runtime': Runtime }
174       )
Note: See TracBrowser for help on using the browser.