File: setup.py

package info (click to toggle)
freevo 1.9.2b2-4.2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 54,120 kB
  • ctags: 17,563
  • sloc: python: 78,224; ansic: 6,829; java: 1,825; sh: 1,352; makefile: 818; xml: 20
file content (212 lines) | stat: -rw-r--r-- 7,372 bytes parent folder | download
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
#!/usr/bin/env python

"""Setup script for the freevo distribution."""


__revision__ = "$Id: setup.py 11834 2011-02-17 20:49:16Z adam $"

# Python distutils stuff
import os
import sys

# Freevo distutils stuff
sys.path.append('./src')
import version
from distutils import core
from distutils.command import install
from util.distribution import setup, Extension, check_libs, docbook_finder
#try:
#    from setuptools import setup
#except ImportError:
#    from util.distribution import setup


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/'),
    ('imdb', 'http://imdbpy.sourceforge.net/'),
    #('Numeric', 'http://numeric.scipy.org/'),
]

files_to_remove = [
    'freevo/util/distutils.py',
    'freevo/util/distutils.pyc',
    'freevo/helpers/imdb.py',
    'freevo/helpers/imdb.pyc',
]

if sys.hexversion < 0x2050000:
    libs_to_check.append(('elementtree', 'http://effbot.org/zone/elementtree.htm'))

#check_libs(libs_to_check)

class CustomInstall(install.install):
    def run(self):
        for filename in files_to_remove:
            path = os.path.join(self.install_lib,filename)
            if os.path.exists(path):
                os.remove(path)
        install.install.run(self)


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')):
    import traceback
    if os.path.isdir('.svn'):
        try:
            import re
            from subprocess import Popen, PIPE
            os.environ['LC_ALL']='C'
            p = Popen(["svn", "info", "--revision=BASE"], stdout=PIPE, env=os.environ)
            info = p.communicate()[0]
            p.wait()
            del(p)
            revision  = re.search('\nRevision: (\d*)\n', info).groups()[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__ = %r\n' % (revision,))
            finally:
                fh.close()
        except Exception, why:
            traceback.print_exc()

    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",
    long_description = "Freevo Multimedia System",
    author           = "Krister Lagerstrom, et al.",
    author_email     = "freevo-devel@lists.sourceforge.net",
    maintainer       = "Adam Charrett",
    maintainer_email = "adam@dvbstreamer.org",
    url              = "http://www.freevo.org",
    license          = "GPL",
    download_url     = "https://sourceforge.net/project/showfiles.php?group_id=46652&package_id=39526",
    i18n             = 'freevo',
    scripts          = scripts,
    data_files       = data_files,
    cmdclass         = { 'runtime': Runtime,
                         'install': CustomInstall},
    classifiers      = [
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: End Users/Desktop",
        "Intended Audience :: Developers",
        "License :: GPL",
        "Programming Language :: Python",
    ],
    platforms       = [ 'Linux', 'FreeBSD', 'Unix' ],
)