duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #03124
[Merge] lp:~ed.so/duplicity/setup.shebang into lp:duplicity
edso has proposed merging lp:~ed.so/duplicity/setup.shebang into lp:duplicity.
Requested reviews:
duplicity-team (duplicity-team)
For more details, see:
https://code.launchpad.net/~ed.so/duplicity/setup.shebang/+merge/275693
having the python interpreter searched in the PATH is much more flexible than the /usr/bin/python inserted into our scripts shebang by setuptools.
this patch prevents that. don't touch my shebang! :)
--
Your team duplicity-team is requested to review the proposed merge of lp:~ed.so/duplicity/setup.shebang into lp:duplicity.
=== modified file 'setup.py'
--- setup.py 2015-02-01 17:37:37 +0000
+++ setup.py 2015-10-26 12:11:13 +0000
@@ -26,6 +26,7 @@
from setuptools.command.test import test
from setuptools.command.install import install
from setuptools.command.sdist import sdist
+from distutils.command.build_scripts import build_scripts
version_string = "$version"
@@ -122,6 +123,44 @@
os.system("mkdir -p " + self.dist_dir)
os.system("mv duplicity-" + version + ".tar.gz " + self.dist_dir)
+# don't touch my shebang
+class BSCommand (build_scripts):
+ def run(self):
+ """
+ Copy, chmod each script listed in 'self.scripts'
+ essentially this is the stripped
+ distutils.command.build_scripts.copy_scripts()
+ routine
+ """
+ from stat import ST_MODE
+ from distutils.dep_util import newer
+ from distutils import log
+
+ self.mkpath(self.build_dir)
+ outfiles = []
+ for script in self.scripts:
+ outfile = os.path.join(self.build_dir, os.path.basename(script))
+ outfiles.append(outfile)
+
+ if not self.force and not newer(script, outfile):
+ log.debug("not copying %s (up-to-date)", script)
+ continue
+
+ log.info("copying and NOT adjusting %s -> %s", script,
+ self.build_dir)
+ self.copy_file(script, outfile)
+
+ if os.name == 'posix':
+ for file in outfiles:
+ if self.dry_run:
+ log.info("changing mode of %s", file)
+ else:
+ oldmode = os.stat(file)[ST_MODE] & 0o7777
+ newmode = (oldmode | 0o555) & 0o7777
+ if newmode != oldmode:
+ log.info("changing mode of %s from %o to %o",
+ file, oldmode, newmode)
+ os.chmod(file, newmode)
setup(name="duplicity",
version=version_string,
@@ -151,5 +190,6 @@
test_suite='testing',
cmdclass={'test': TestCommand,
'install': InstallCommand,
- 'sdist': SDistCommand},
+ 'sdist': SDistCommand,
+ 'build_scripts': BSCommand},
)
Follow ups