~facundo/enjuewemela/trunk

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Facundo Batista
  • Date: 2011-08-23 16:19:08 UTC
  • Revision ID: facundo@taniquetil.com.ar-20110823161908-56h0twnys4kp14fa
Final setup.py and stuff to have it installed in desktop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        # make the distutils infrastructure run
36
36
        install.run(self)
37
37
 
38
 
        # fix the desktop icon
39
 
        desktop_file = os.path.join(self._custom_data_dir,
40
 
                                    'enjuewemela.desktop.in')
41
 
        if os.access(desktop_file, os.W_OK):
42
 
            with open(desktop_file, 'rb') as fh:
43
 
                content = fh.read()
44
 
            icon = os.path.join(self._custom_data_dir,
45
 
                                'enjuewemela', 'images', 'icon-32x32.png')
46
 
            content = content.replace('@ INSTALLED_ICON @', icon)
47
 
            with open(desktop_file, 'wb') as fh:
48
 
                fh.write(content)
49
 
 
50
38
        # fix installation path in the script(s)
51
39
        for script in self.distribution.scripts:
52
40
            script_path = os.path.join(self.install_scripts,
58
46
            with open(script_path, 'wb') as fh:
59
47
                fh.write(content)
60
48
 
 
49
        # fix the icon path, and save the .desktop file where it should be
 
50
        src_desktop = self.distribution.get_name() + '.desktop'
 
51
        if not os.path.exists(self._custom_apps_dir):
 
52
            os.makedirs(self._custom_apps_dir)
 
53
        dst_desktop = os.path.join(self._custom_apps_dir, src_desktop)
 
54
 
 
55
        with open(src_desktop, 'rb') as fh:
 
56
            content = fh.read()
 
57
        icon = os.path.join(self._custom_data_dir,
 
58
                            'enjuewemela', 'images', 'icon-32x32.png')
 
59
        content = content.replace('@ INSTALLED_ICON @', icon)
 
60
        with open(dst_desktop, 'wb') as fh:
 
61
            fh.write(content)
 
62
 
61
63
 
62
64
    def finalize_options(self):
63
65
        """Alter the installation path."""
66
68
        # the data path is under 'prefix'
67
69
        data_dir = os.path.join(self.prefix, "share",
68
70
                                self.distribution.get_name())
 
71
        apps_dir = os.path.join(self.prefix, "share", "applications")
69
72
 
70
73
        # if we have 'root', put the building path also under it (used normally
71
74
        # by pbuilder)
73
76
            build_dir = data_dir
74
77
        else:
75
78
            build_dir = os.path.join(self.root, data_dir[1:])
 
79
            apps_dir = os.path.join(self.root, apps_dir[1:])
76
80
 
77
81
        # change the lib install directory so all package files go inside here
78
82
        self.install_lib = build_dir
79
83
 
80
84
        # save this custom data dir to later change the scripts
81
85
        self._custom_data_dir = data_dir
 
86
        self._custom_apps_dir = apps_dir
82
87
 
83
88
 
84
89
def recursive(base, dirs):