Merge lp:~ed.so/duplicity/setup.shebang into lp:~duplicity-team/duplicity/0.7-series

Proposed by edso
Status: Merged
Merged at revision: 1138
Proposed branch: lp:~ed.so/duplicity/setup.shebang
Merge into: lp:~duplicity-team/duplicity/0.7-series
Diff against target: 71 lines (+43/-3)
1 file modified
setup.py (+43/-3)
To merge this branch: bzr merge lp:~ed.so/duplicity/setup.shebang
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+275693@code.launchpad.net

Description of the change

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! :)

To post a comment you must log in.
lp:~ed.so/duplicity/setup.shebang updated
1137. By edso

also check python version number upper bound. we run on 2.6 and 2.7 currently

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2015-02-01 17:37:37 +0000
3+++ setup.py 2015-10-26 15:47:21 +0000
4@@ -26,11 +26,12 @@
5 from setuptools.command.test import test
6 from setuptools.command.install import install
7 from setuptools.command.sdist import sdist
8+from distutils.command.build_scripts import build_scripts
9
10 version_string = "$version"
11
12-if sys.version_info[:2] < (2, 6):
13- print("Sorry, duplicity requires version 2.6 or later of python")
14+if sys.version_info[:2] < (2, 6) or sys.version_info[:2] > (2, 7):
15+ print("Sorry, duplicity requires version 2.6 or 2.7 of python.")
16 sys.exit(1)
17
18 incdir_list = libdir_list = None
19@@ -122,6 +123,44 @@
20 os.system("mkdir -p " + self.dist_dir)
21 os.system("mv duplicity-" + version + ".tar.gz " + self.dist_dir)
22
23+# don't touch my shebang
24+class BSCommand (build_scripts):
25+ def run(self):
26+ """
27+ Copy, chmod each script listed in 'self.scripts'
28+ essentially this is the stripped
29+ distutils.command.build_scripts.copy_scripts()
30+ routine
31+ """
32+ from stat import ST_MODE
33+ from distutils.dep_util import newer
34+ from distutils import log
35+
36+ self.mkpath(self.build_dir)
37+ outfiles = []
38+ for script in self.scripts:
39+ outfile = os.path.join(self.build_dir, os.path.basename(script))
40+ outfiles.append(outfile)
41+
42+ if not self.force and not newer(script, outfile):
43+ log.debug("not copying %s (up-to-date)", script)
44+ continue
45+
46+ log.info("copying and NOT adjusting %s -> %s", script,
47+ self.build_dir)
48+ self.copy_file(script, outfile)
49+
50+ if os.name == 'posix':
51+ for file in outfiles:
52+ if self.dry_run:
53+ log.info("changing mode of %s", file)
54+ else:
55+ oldmode = os.stat(file)[ST_MODE] & 0o7777
56+ newmode = (oldmode | 0o555) & 0o7777
57+ if newmode != oldmode:
58+ log.info("changing mode of %s from %o to %o",
59+ file, oldmode, newmode)
60+ os.chmod(file, newmode)
61
62 setup(name="duplicity",
63 version=version_string,
64@@ -151,5 +190,6 @@
65 test_suite='testing',
66 cmdclass={'test': TestCommand,
67 'install': InstallCommand,
68- 'sdist': SDistCommand},
69+ 'sdist': SDistCommand,
70+ 'build_scripts': BSCommand},
71 )

Subscribers

People subscribed via source and target branches