Merge lp:~spud/spud/fix-bug-931800 into lp:spud

Proposed by Tim Greaves
Status: Merged
Merged at revision: 517
Proposed branch: lp:~spud/spud/fix-bug-931800
Merge into: lp:spud
Diff against target: 91 lines (+41/-5)
2 files modified
debian/rules (+1/-1)
diamond/setup.py.in (+40/-4)
To merge this branch: bzr merge lp:~spud/spud/fix-bug-931800
Reviewer Review Type Date Requested Status
David Ham Approve
Review via email: mp+94775@code.launchpad.net

Description of the change

Responding to bug lp:931800, this merge:

* Changes the call to setup.py from debian/rules to use --root=path as opposed
   to --root path
* Adds in parsing of sys.argv to pull out that root and use it as destdir

A test build on precise appears to behave nicely.

To post a comment you must log in.
lp:~spud/spud/fix-bug-931800 updated
517. By Tim Greaves

Apologies; committed the wrong version of this file.

Revision history for this message
David Ham (david-ham) wrote :

This looks like it fixes the functionality, but the semantics of this routine are starting to get a little complex. Maybe add a few lines of comments indicating what it does when used from the package, from the makefile and directly so that next time this breaks we can remember it?

lp:~spud/spud/fix-bug-931800 updated
518. By Tim Greaves

Updating from the trunk.

519. By Tim Greaves

Adding some commenting to (hopefully) make this all clearer-than-mud next time
something breaks.

520. By Tim Greaves

A little more commenting, in an attempt to further clarify the install mess.

Revision history for this message
Tim Greaves (tim-greaves) wrote :

Comments added; anyone for some reviewing?

Revision history for this message
David Ham (david-ham) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/rules'
2--- debian/rules 2011-11-21 22:01:58 +0000
3+++ debian/rules 2012-02-27 17:12:19 +0000
4@@ -71,7 +71,7 @@
5
6 install-python%:
7 # Force setuptools, but reset sys.argv[0] to 'setup.py' because setup.py files expect that.
8- cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;execfile(f,{'__file__':f,'__name__':'__main__'})" install --prefix=/usr --no-compile --single-version-externally-managed --root $(CURDIR)/debian/${PACKAGE_NAME}
9+ cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;execfile(f,{'__file__':f,'__name__':'__main__'})" install --prefix=/usr --no-compile --single-version-externally-managed --root=$(CURDIR)/debian/${PACKAGE_NAME}
10 if [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info ]; then \
11 mv debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}.egg-info ; \
12 elif [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}-py$*.egg-info ]; then \
13
14=== modified file 'diamond/setup.py.in'
15--- diamond/setup.py.in 2012-01-31 14:38:57 +0000
16+++ diamond/setup.py.in 2012-02-27 17:12:19 +0000
17@@ -4,19 +4,54 @@
18 import os.path
19 import glob
20
21+# There are a number of local hacks in this file, to deal with the multiple
22+# ways in which setup.py is called by various scripts and packaging methods
23+# that interact with spud, enabling setuptools to grok their intentions.
24+
25+# In some cases, we will be passed a 'DESTDIR' from an upstream packagaing
26+# system. This will be a local directory to install into, and act as local '/'
27+# as far as all paths are concerned. Check for this, and fail nicely if not set.
28+
29 try:
30 destdir = os.environ["DESTDIR"]
31 except KeyError:
32 destdir = ""
33
34+
35 prefix = None
36 import sys
37+
38+# We may also be given prefix, either as a configuration option (which will be
39+# dealt with by substitutions later) or as a command line option. If a command
40+# line option is present, parse this. In some cases, just to add spice into the
41+# mix, PREFIX is supplied twice - once by configure, and again by a parent
42+# Makefile as a command-line flag.
43+#
44+# As an alternative to DESTDIR being set, Debian packaging calls setup.py with
45+# a --root command line option which does the same thing. This needs to be
46+# parsed if present, and supercedes any previous DESTDIR picked up from
47+# environment.
48+
49 for i, arg in enumerate(sys.argv):
50 if "--prefix" in arg:
51 prefix = arg.split('=')[1]
52- break
53-
54-# Get all the plugin directories we have
55+ if "--root" in arg:
56+ destdir = arg.split('=')[1]
57+
58+# Given the above prefix possibilities, as well as root and DESTDIR, we need to
59+# construct a list of data directories to be installed
60+#
61+# * configure-supplied prefixes are dealt with by substitution directly into
62+# this file, with @ PREFIX @ being replaced.
63+# * prefixes as command-line options are pushed by us
64+# * DESTDIR and root have now been condensed into 'destdir' and are pushed
65+# by us
66+#
67+# Note that in the case of this and other packages which supply prefix twice
68+# (once in configure, and then again on the command line) we honour the prefix
69+# on the command line in preference to the configure prefix.
70+
71+# First parse the plugin directories
72 plugin_dirs = [dir for dir in os.listdir('plugins') if os.path.isdir(os.path.join('plugins', dir)) and dir[0] != '.']
73 plugin_data_files = []
74 for plugin in plugin_dirs:
75@@ -27,7 +62,7 @@
76 plugin_data_files.append((destdir + "/" + prefix + "/share/diamond/plugins/" + plugin,
77 glob.glob('plugins/' + plugin + '/*.py')))
78
79-# Consider whether we honour the configure or the setup prefix
80+# Now parse the GUI directories
81 gui_data_files = []
82 if prefix is None:
83 gui_data_files.append((destdir + "@prefix@/share/diamond/gui",
84@@ -36,6 +71,7 @@
85 gui_data_files.append((destdir + "/" + prefix + "/share/diamond/gui",
86 ["gui/gui.glade", "gui/diamond.svg"]))
87
88+# We now have all the information we need; run setup.
89 setup(
90 name='diamond',
91 version='1.0',

Subscribers

People subscribed via source and target branches