~soaringsky/pithos/743198

1 by Kevin Mehall
Initial project creation with Quickly!
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
### BEGIN LICENSE
9 by Kevin Mehall
license under GPLv3
4
# Copyright (C) 2010 Kevin Mehall <km@kevinmehall.net>
5
#This program is free software: you can redistribute it and/or modify it 
6
#under the terms of the GNU General Public License version 3, as published 
7
#by the Free Software Foundation.
8
#
9
#This program is distributed in the hope that it will be useful, but 
10
#WITHOUT ANY WARRANTY; without even the implied warranties of 
11
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
12
#PURPOSE.  See the GNU General Public License for more details.
13
#
14
#You should have received a copy of the GNU General Public License along 
15
#with this program.  If not, see <http://www.gnu.org/licenses/>.
1 by Kevin Mehall
Initial project creation with Quickly!
16
### END LICENSE
17
18
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
19
20
try:
21
    import DistUtilsExtra.auto
22
except ImportError:
23
    import sys
24
    print >> sys.stderr, 'To build pithos you need https://launchpad.net/python-distutils-extra'
25
    sys.exit(1)
26
27
assert DistUtilsExtra.auto.__version__ >= '2.10', 'needs DistUtilsExtra.auto >= 2.10'
28
import os
29
30
31
def update_data_path(prefix, oldvalue=None):
32
33
    try:
34
        fin = file('pithos/pithosconfig.py', 'r')
35
        fout = file(fin.name + '.new', 'w')
36
37
        for line in fin:            
38
            fields = line.split(' = ') # Separate variable from value
39
            if fields[0] == '__pithos_data_directory__':
40
                # update to prefix, store oldvalue
41
                if not oldvalue:
42
                    oldvalue = fields[1]
43
                    line = "%s = '%s'\n" % (fields[0], prefix)
44
                else: # restore oldvalue
45
                    line = "%s = %s" % (fields[0], oldvalue)
46
            fout.write(line)
47
48
        fout.flush()
49
        fout.close()
50
        fin.close()
51
        os.rename(fout.name, fin.name)
52
    except (OSError, IOError), e:
53
        print ("ERROR: Can't find pithos/pithosconfig.py")
54
        sys.exit(1)
55
    return oldvalue
56
57
58
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
59
    def run(self):
60
        if self.root or self.home:
61
            print "WARNING: You don't use a standard --prefix installation, take care that you eventually " \
62
            "need to update quickly/quicklyconfig.py file to adjust __quickly_data_directory__. You can " \
63
            "ignore this warning if you are packaging and uses --prefix."
64
        previous_value = update_data_path(self.prefix + '/share/pithos/')
65
        DistUtilsExtra.auto.install_auto.run(self)
66
        update_data_path(self.prefix, previous_value)
67
159.1.5 by Kevin Mehall
Use themable icons, also fixing the icon in the sound menu
68
from DistUtilsExtra.command.build_extra import build_extra
69
from DistUtilsExtra.command.build_icons import build_icons
1 by Kevin Mehall
Initial project creation with Quickly!
70
10 by Kevin Mehall
packaging changes
71
DistUtilsExtra.auto.setup(
72
    name='pithos',
118 by Kevin Mehall
Version bump (0.3)
73
    version='0.3',
98.1.3 by Kevin Mehall
Update packaging to reflect removal of C dependency
74
    ext_modules=[],
9 by Kevin Mehall
license under GPLv3
75
    license='GPL-3',
6 by Kevin Mehall
make setup.py compile libpiano module
76
    author='Kevin Mehall',
77
    author_email='km@kevinmehall.net',
78
    description='Pandora.com client for the GNOME desktop',
1 by Kevin Mehall
Initial project creation with Quickly!
79
    #long_description='Here a longer description',
6 by Kevin Mehall
make setup.py compile libpiano module
80
    url='https://launchpad.net/pithos',
159.1.5 by Kevin Mehall
Use themable icons, also fixing the icon in the sound menu
81
    cmdclass={'install': InstallAndUpdateDataDirectory, 'build_icons':build_icons, 'build':build_extra}
1 by Kevin Mehall
Initial project creation with Quickly!
82
    )
83