summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 03188c94..8d762013 100755
--- a/setup.py
+++ b/setup.py
@@ -4,19 +4,26 @@
 
 from __future__ import (absolute_import, division, print_function)
 
+from distutils import log  # pylint: disable=import-error,no-name-in-module
 from hashlib import sha512
 import os
 import shutil
 
 import ranger
 
+
+SCRIPTS_PATH = 'build_scripts'
+EXECUTABLES_PATHS = ['/ranger/data/scope.sh']
+
+
+# pylint: disable=import-error,no-name-in-module,ungrouped-imports
 if os.environ.get('SETUPTOOLS_USE'):
     from setuptools import setup
+    from setuptools.command.install_lib import install_lib
 else:
-    from distutils.core import setup  # pylint: disable=import-error,no-name-in-module
-
-
-SCRIPTS_PATH = 'build_scripts'
+    from distutils.core import setup
+    from distutils.command.install_lib import install_lib
+# pylint: enable=import-error,no-name-in-module,ungrouped-imports
 
 
 def findall(directory):
@@ -43,6 +50,19 @@ def scripts_hack(*scripts):
     return scripts_path
 
 
+class InstallLib(install_lib):
+    def run(self):
+        install_lib.run(self)
+
+        # Make executables executable
+        for path in self.get_outputs():
+            for exe_path in EXECUTABLES_PATHS:
+                if path.endswith(exe_path):
+                    mode = ((os.stat(path).st_mode) | 0o555) & 0o7777
+                    log.info('changing mode of %s to %o', path, mode)
+                    os.chmod(path, mode)
+
+
 def main():
     setup(
         name='ranger-fm',
@@ -76,6 +96,8 @@ def main():
             'Topic :: Utilities',
         ],
 
+        cmdclass={'install_lib': InstallLib},
+
         scripts=scripts_hack(
             ('ranger.py', 'ranger'),
             ('ranger/ext/rifle.py', 'rifle'),