kuuko pushed a commit to branch master.

http://git.enlightenment.org/misc/polkit-efl.git/commit/?id=c9061df9ae08add62b9d83b1843a28d5c9beb348

commit c9061df9ae08add62b9d83b1843a28d5c9beb348
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Fri Jun 20 09:10:18 2014 +0300

    Allow the script install location to be overridden
---
 setup.py | 73 ++++++++++++++++++++++++++++++----------------------------------
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/setup.py b/setup.py
index ed39fe0..d65e502 100755
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,10 @@
 #!/usr/bin/python
 
+from distutils import log
 from distutils.core import setup, Command
 from distutils.log import info, error
 from distutils.command.build import build
+from distutils.command.install_scripts import install_scripts
 from distutils.dep_util import newer
 from distutils.errors import DistutilsFileError
 from sys import exec_prefix
@@ -85,54 +87,19 @@ class BuildL10N(Command):
                     else:
                         shutil.copymode(po_path, mo_path)
 
-
-class PrepareDesktop(Command):
-    description = 'Adds Exec line to .desktop file'
-    user_options = []
-
-    def initialize_options(self):
-        pass
-
-    def finalize_options(self):
-        pass
-
-    def run(self):
-        if not self.dry_run:
-            in_path = 'data/polkit-efl-authentication-agent-1.desktop.in'
-            out_path = 'data/polkit-efl-authentication-agent-1.desktop'
-            if os.path.exists(in_path):
-                if newer(in_path, out_path):
-                    with open(
-                        in_path, 'r'
-                            ) as src:
-                        tmp = src.read()
-
-                    with open(
-                        out_path, 'w'
-                            ) as dest:
-                        dest.write(tmp)
-                        dest.write(
-                            
"Exec=%s/libexec/polkit-efl-authentication-agent-1\n" % (
-                                exec_prefix
-                                )
-                            )
-
-
 data_files = [
     (
         '/etc/xdg/autostart',
         ['data/polkit-efl-authentication-agent-1.desktop']
         ),
     (
-        '%s/libexec' % (exec_prefix),
-        ['polkit-efl-authentication-agent-1']
-        ),
-    (
         '%s/share/polkit-efl/theme' % (exec_prefix),
         ['data/theme/default.edj']
         )
     ]
 
+scripts = ['polkit-efl-authentication-agent-1']
+
 for po_dir, lang, mo_path, po_path in get_l10n_files():
     data_files.append(
         (
@@ -146,11 +113,38 @@ for po_dir, lang, mo_path, po_path in get_l10n_files():
 
 class Build(build):
     def run(self):
-        self.run_command("prepare_desktop")
         self.run_command("build_themes")
         self.run_command("build_l10n")
         build.run(self)
 
+
+class InstallScripts(install_scripts):
+    def run(self):
+        exec_path = os.path.join(
+            self.install_dir, "polkit-efl-authentication-agent-1"
+            )
+        in_path = 'data/polkit-efl-authentication-agent-1.desktop.in'
+        out_path = 'data/polkit-efl-authentication-agent-1.desktop'
+        if os.path.exists(in_path):
+            log.info("modifying .desktop file's Exec to %s" % exec_path)
+            if not self.dry_run:
+                with open(
+                    in_path, 'r'
+                        ) as src:
+                    tmp = src.read()
+
+                with open(
+                    out_path, 'w'
+                        ) as dest:
+                    dest.write(tmp)
+                    dest.write(
+                        "Exec=%s\n" % (
+                            exec_path
+                            )
+                        )
+        install_scripts.run(self)
+
+
 setup(
     name='polkit-efl',
     version='0.1.0',
@@ -168,10 +162,11 @@ setup(
         'python_efl',
         ],
     data_files=data_files,
+    scripts=scripts,
     cmdclass={
-        'prepare_desktop': PrepareDesktop,
         'build_themes': BuildThemes,
         'build_l10n': BuildL10N,
         'build': Build,
+        'install_scripts': InstallScripts,
         },
     )

-- 


Reply via email to