summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-11 16:02:56 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-11 16:02:56 +0000
commit86487edbf05f712bf6b351ae639cd10bcf87ba63 (patch)
tree11868958914713bfd42d9dba6a563365ed706ef1
parent248910daf2da468c4c11b8edbf7cfdf0725918b2 (diff)
downloadimport-86487edbf05f712bf6b351ae639cd10bcf87ba63.tar.gz
setup.py: Force import extensions to have execute permissions preserved
Code for this was taken from Morph's setup.py file. It would possibly be more correct to install these files into a subdirectory of /usr/libexec but it'd be a more complex solution for little actual benefit.
-rw-r--r--setup.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index f8396ef..7a30fcc 100644
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,29 @@
from distutils.core import setup
+from distutils.command.build import build
+
+import os
+import os.path
+import stat
+
+
+class GenerateResources(build):
+
+ def run(self):
+ build.run(self)
+
+ # Set exec permissions on import extensions.
+ for dirname, subdirs, basenames in os.walk('baserockimport/exts'):
+ for basename in basenames:
+ orig = os.path.join(dirname, basename)
+ built = os.path.join('build/lib', dirname, basename)
+ st = os.lstat(orig)
+ bits = (st.st_mode &
+ (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
+ if bits != 0:
+ st2 = os.lstat(built)
+ os.chmod(built, st2.st_mode | bits)
setup(name='baserockimport',
@@ -44,4 +67,7 @@ setup(name='baserockimport',
'exts/*',
]
},
+ cmdclass={
+ 'build': GenerateResources,
+ }
)