~mtrovo/pomodoro-indicator/main

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Marcos Alejandro Vanetta
  • Date: 2011-08-26 04:56:46 UTC
  • Revision ID: git-v1:706dcfdd0e620ba9c2a7a9423bcd1fefc9902621
reconfigure towards setup.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#-*- coding:utf-8 -*-
 
3
 
 
4
#
 
5
# Copyright 2011 malev.com.ar
 
6
#
 
7
# Author: Marcos Vanetta <marcosvanetta@gmail.com>
 
8
#
 
9
# This program is free software: you can redistribute it and/or modify it
 
10
# under the terms of either or both of the following licenses:
 
11
#
 
12
# 1) the GNU Lesser General Public License version 3, as published by the
 
13
# Free Software Foundation; and/or
 
14
# 2) the GNU Lesser General Public License version 2.1, as published by
 
15
# the Free Software Foundation.
 
16
#
 
17
# This program is distributed in the hope that it will be useful, but
 
18
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
19
# MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
20
# PURPOSE.  See the applicable version of the GNU Lesser General Public
 
21
# License for more details.
 
22
#
 
23
# You should have received a copy of both the GNU Lesser General Public
 
24
# License version 3 and version 2.1 along with this program.  If not, see
 
25
# <http://www.gnu.org/licenses/>
 
26
#
 
27
 
 
28
"""Build tar.gz for pomodoro-indicator.
 
29
Needed packages to run (using Debian/Ubuntu package names):
 
30
    python-zope.testbrowser 3.5.1
 
31
    python-mechanize 0.1.11
 
32
    python-twisted-bin 8.2.0
 
33
    python-gtk2 2.16.0
 
34
    python-xdg 0.15
 
35
"""
 
36
 
 
37
 
 
38
import os
 
39
 
 
40
from distutils.command.install import install
 
41
from distutils.core import setup
 
42
 
 
43
 
 
44
class CustomInstall(install):
 
45
    """Custom installation class on package files.
 
46
 
 
47
    It copies all the files into the "PREFIX/share/PROJECTNAME" dir.
 
48
    """
 
49
    def run(self):
 
50
        """Run parent install, and then save the install dir in the script."""
 
51
        install.run(self)
 
52
 
 
53
        for script in self.distribution.scripts:
 
54
            script_path = os.path.join(self.install_scripts,
 
55
                                       os.path.basename(script))
 
56
            with open(script_path, 'rb') as fh:
 
57
                content = fh.read()
 
58
            content = content.replace('@ INSTALLED_BASE_DIR @',
 
59
                                      self._custom_data_dir)
 
60
            with open(script_path, 'wb') as fh:
 
61
                fh.write(content)
 
62
 
 
63
 
 
64
    def finalize_options(self):
 
65
        """Alter the installation path."""
 
66
        install.finalize_options(self)
 
67
 
 
68
        # the data path is under 'prefix'
 
69
        data_dir = os.path.join(self.prefix, "share",
 
70
                                self.distribution.get_name())
 
71
 
 
72
        # if we have 'root', put the building path also under it (used normally
 
73
        # by pbuilder)
 
74
        if self.root is None:
 
75
            build_dir = data_dir
 
76
        else:
 
77
            build_dir = os.path.join(self.root, data_dir[1:])
 
78
 
 
79
        # change the lib install directory so all package files go inside here
 
80
        self.install_lib = build_dir
 
81
 
 
82
        # save this custom data dir to later change the scripts
 
83
        self._custom_data_dir = data_dir
 
84
 
 
85
 
 
86
setup(
 
87
    name = 'pomodoro-indicator',
 
88
    version = '0.0.1',
 
89
    license = 'GPL-3',
 
90
    author = 'Marcos Vanetta',
 
91
    author_email = 'marcosvanetta@gmail.com',
 
92
    description = 'Pomodoro technique app indicator.',
 
93
    long_description = 'Pomodoro technique app indicator',
 
94
    url = 'https://github.com/malev/pomodoro-indicator',
 
95
 
 
96
    packages = ["pomodoro-indicator"],
 
97
    package_data = {"pomodoro-indicator": ["images/*.png"]},
 
98
    scripts = ["bin/pomodoro-indicator"],
 
99
 
 
100
    cmdclass = {
 
101
        'install': CustomInstall,
 
102
    }
 
103
)