Merge lp:~francesco-marella/specto/fix-sdist into lp:specto
- fix-sdist
- Merge into main
Proposed by
Francesco Marella
Status: | Merged |
---|---|
Merged at revision: | 174 |
Proposed branch: | lp:~francesco-marella/specto/fix-sdist |
Merge into: | lp:specto |
Diff against target: |
326 lines (+117/-125) 7 files modified
VERSION (+0/-1) setup.py (+102/-101) spectlib/__init__.py (+3/-0) spectlib/constants.py.in (+0/-7) spectlib/i18n.py (+6/-6) spectlib/main.py (+1/-6) spectlib/util.py (+5/-4) |
To merge this branch: | bzr merge lp:~francesco-marella/specto/fix-sdist |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeff Fortin Tam | Needs Fixing | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'VERSION' | |||
2 | --- VERSION 2011-06-23 18:55:56 +0000 | |||
3 | +++ VERSION 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,1 +0,0 @@ | |||
5 | 1 | 0.4 | ||
6 | 2 | 0 | ||
7 | === added directory 'data/desktop' | |||
8 | === renamed file 'specto.desktop.in' => 'data/desktop/specto.desktop.in' | |||
9 | === modified file 'setup.py' | |||
10 | --- setup.py 2011-01-07 12:40:33 +0000 | |||
11 | +++ setup.py 2011-08-10 10:01:36 +0000 | |||
12 | @@ -12,6 +12,17 @@ | |||
13 | 12 | 12 | ||
14 | 13 | INSTALLED_FILES = "installed_files" | 13 | INSTALLED_FILES = "installed_files" |
15 | 14 | 14 | ||
16 | 15 | from spectlib import __pkg_version__ as version | ||
17 | 16 | |||
18 | 17 | def give_files(dir, *extension): | ||
19 | 18 | files=[] | ||
20 | 19 | all_files=os.listdir(dir) | ||
21 | 20 | for file in all_files: | ||
22 | 21 | ext=(os.path.splitext(file))[1] | ||
23 | 22 | if ext in extension: | ||
24 | 23 | files.append(dir + file) | ||
25 | 24 | return files | ||
26 | 25 | |||
27 | 15 | class install (_install): | 26 | class install (_install): |
28 | 16 | 27 | ||
29 | 17 | def run (self): | 28 | def run (self): |
30 | @@ -78,60 +89,46 @@ | |||
31 | 78 | print "Please specify operation : %s" % " | ".join (ops) | 89 | print "Please specify operation : %s" % " | ".join (ops) |
32 | 79 | raise SystemExit | 90 | raise SystemExit |
33 | 80 | 91 | ||
88 | 81 | prefix = None | 92 | |
89 | 82 | if len (sys.argv) > 2: | 93 | if sys.argv[1] in ("build", "install"): |
90 | 83 | i = 0 | 94 | prefix = None |
91 | 84 | for o in sys.argv: | 95 | if len (sys.argv) > 2: |
92 | 85 | if o.startswith ("--prefix"): | 96 | i = 0 |
93 | 86 | if o == "--prefix": | 97 | for o in sys.argv: |
94 | 87 | if len (sys.argv) >= i: | 98 | if o.startswith ("--prefix"): |
95 | 88 | prefix = sys.argv[i + 1] | 99 | if o == "--prefix": |
96 | 89 | sys.argv.remove (prefix) | 100 | if len (sys.argv) >= i: |
97 | 90 | elif o.startswith ("--prefix=") and len (o[9:]): | 101 | prefix = sys.argv[i + 1] |
98 | 91 | prefix = o[9:] | 102 | sys.argv.remove (prefix) |
99 | 92 | sys.argv.remove (o) | 103 | elif o.startswith ("--prefix=") and len (o[9:]): |
100 | 93 | break | 104 | prefix = o[9:] |
101 | 94 | i += 1 | 105 | sys.argv.remove (o) |
102 | 95 | if not prefix and "PREFIX" in os.environ: | 106 | break |
103 | 96 | prefix = os.environ["PREFIX"] | 107 | i += 1 |
104 | 97 | if not prefix or not len (prefix): | 108 | if not prefix and "PREFIX" in os.environ: |
105 | 98 | prefix = "/usr/local" | 109 | prefix = os.environ["PREFIX"] |
106 | 99 | 110 | if not prefix or not len (prefix): | |
107 | 100 | if sys.argv[1] in ("install", "uninstall") and len (prefix): | 111 | prefix = sys.prefix |
108 | 101 | sys.argv += ["--prefix", prefix] | 112 | if not prefix or not len (prefix): |
109 | 102 | 113 | prefix = "/usr/local" | |
110 | 103 | with open("VERSION", "r") as version_file: | 114 | |
111 | 104 | version = version_file.read().strip() | 115 | if sys.argv[1] in ("install", "uninstall") and len (prefix): |
112 | 105 | 116 | sys.argv += ["--prefix", prefix] | |
113 | 106 | with open(os.path.join ("spectlib/constants.py.in"), "rt") as file_in: | 117 | |
114 | 107 | data = file_in.read () | 118 | if sys.argv[1] == "build": |
115 | 108 | data = data.replace ("@prefix@", prefix) | 119 | with open(os.path.join("data/indicator/specto.in"), "rt") as file_in: |
116 | 109 | data = data.replace ("@version@", version) | 120 | data = file_in.read() |
117 | 110 | with open (os.path.join ("spectlib/constants.py"), "wt") as file_out: | 121 | data = data.replace("@prefix@", prefix) |
118 | 111 | file_out.write (data) | 122 | with open (os.path.join ("data/indicator/specto"), "wt") as file_out: |
119 | 112 | 123 | file_out.write(data) | |
120 | 113 | with open(os.path.join("data/indicator/specto.in"), "rt") as file_in: | 124 | |
121 | 114 | data = file_in.read() | 125 | cmd = "intltool-merge -d -u po/ data/desktop/specto.desktop.in specto.desktop".split(" ") |
122 | 115 | data = data.replace("@prefix@", prefix) | 126 | try: |
123 | 116 | with open (os.path.join ("data/indicator/specto"), "wt") as file_out: | 127 | proc = subprocess.Popen(cmd) |
124 | 117 | file_out.write(data) | 128 | proc.wait() |
125 | 118 | 129 | except: | |
126 | 119 | cmd = "intltool-merge -d -u po/ specto.desktop.in specto.desktop".split(" ") | 130 | print "Error: intltool-merge not found, please install the intltool package." |
127 | 120 | try: | 131 | raise SystemExit |
74 | 121 | proc = subprocess.Popen(cmd) | ||
75 | 122 | proc.wait() | ||
76 | 123 | except: | ||
77 | 124 | print "Error: intltool-merge not found, please install the intltool package." | ||
78 | 125 | raise SystemExit | ||
79 | 126 | |||
80 | 127 | def give_files(dir, *extension): | ||
81 | 128 | files=[] | ||
82 | 129 | all_files=os.listdir(dir) | ||
83 | 130 | for file in all_files: | ||
84 | 131 | ext=(os.path.splitext(file))[1] | ||
85 | 132 | if ext in extension: | ||
86 | 133 | files.append(dir + file) | ||
87 | 134 | return files | ||
128 | 135 | 132 | ||
129 | 136 | custom_images = [] | 133 | custom_images = [] |
130 | 137 | 134 | ||
131 | @@ -145,47 +142,55 @@ | |||
132 | 145 | global_icon_path = "share/icons/hicolor" | 142 | global_icon_path = "share/icons/hicolor" |
133 | 146 | local_icon_path = "share/specto/icons/hicolor/" | 143 | local_icon_path = "share/specto/icons/hicolor/" |
134 | 147 | 144 | ||
176 | 148 | for dir, subdirs, files in os.walk("data/icons/"): | 145 | if sys.argv[1] in ("build", "install"): |
177 | 149 | if dir == "data/icons/": | 146 | for dir, subdirs, files in os.walk("data/icons/"): |
178 | 150 | for file in files: | 147 | if dir == "data/icons/": |
179 | 151 | custom_images.append(dir + file) | 148 | for file in files: |
180 | 152 | else: | 149 | custom_images.append(dir + file) |
181 | 153 | images = [] | 150 | else: |
182 | 154 | global_images = [] | 151 | images = [] |
183 | 155 | 152 | global_images = [] | |
184 | 156 | for file in files: | 153 | |
185 | 157 | if file.find(".svg") or file.find(".png"): | 154 | for file in files: |
186 | 158 | file_path = "%s/%s" % (dir, file) | 155 | if file.find(".svg") or file.find(".png"): |
187 | 159 | # global image | 156 | file_path = "%s/%s" % (dir, file) |
188 | 160 | if file[:-4] == "specto": | 157 | # global image |
189 | 161 | global_images.append(file_path) | 158 | if file[:-4] == "specto": |
190 | 162 | # local image | 159 | global_images.append(file_path) |
191 | 163 | else: | 160 | # local image |
192 | 164 | images.append(file_path) | 161 | else: |
193 | 165 | # local | 162 | images.append(file_path) |
194 | 166 | if len(images) > 0: | 163 | # local |
195 | 167 | data_files.append((local_icon_path + dir[10:], images)) | 164 | if len(images) > 0: |
196 | 168 | # global | 165 | data_files.append((local_icon_path + dir[10:], images)) |
197 | 169 | if len(global_images) > 0: | 166 | # global |
198 | 170 | data_files.append((global_icon_path + dir[10:], global_images)) | 167 | if len(global_images) > 0: |
199 | 171 | 168 | data_files.append((global_icon_path + dir[10:], global_images)) | |
200 | 172 | data_files.append(("share/specto/icons/", custom_images)) | 169 | |
201 | 173 | 170 | data_files.append(("share/specto/icons/", custom_images)) | |
202 | 174 | podir = os.path.join (os.path.realpath ("."), "po") | 171 | |
203 | 175 | if os.path.isdir (podir): | 172 | podir = os.path.join (os.path.realpath ("."), "po") |
204 | 176 | buildcmd = "msgfmt -o build/locale/%s/specto.mo po/%s.po" | 173 | if os.path.isdir (podir): |
205 | 177 | mopath = "build/locale/%s/specto.mo" | 174 | buildcmd = "msgfmt -o build/locale/%s/specto.mo po/%s.po" |
206 | 178 | destpath = "share/locale/%s/LC_MESSAGES" | 175 | mopath = "build/locale/%s/specto.mo" |
207 | 179 | for name in os.listdir (podir): | 176 | destpath = "share/locale/%s/LC_MESSAGES" |
208 | 180 | if name[-2:] == "po": | 177 | for name in os.listdir (podir): |
209 | 181 | name = name[:-3] | 178 | if name[-2:] == "po": |
210 | 182 | if sys.argv[1] == "build" \ | 179 | name = name[:-3] |
211 | 183 | or (sys.argv[1] == "install" and \ | 180 | if sys.argv[1] == "build" \ |
212 | 184 | not os.path.exists (mopath % name)): | 181 | or (sys.argv[1] == "install" and \ |
213 | 185 | if not os.path.isdir ("build/locale/" + name): | 182 | not os.path.exists (mopath % name)): |
214 | 186 | os.makedirs ("build/locale/" + name) | 183 | if not os.path.isdir ("build/locale/" + name): |
215 | 187 | os.system (buildcmd % (name, name)) | 184 | os.makedirs ("build/locale/" + name) |
216 | 188 | data_files.append ((destpath % name, [mopath % name])) | 185 | os.system (buildcmd % (name, name)) |
217 | 186 | data_files.append ((destpath % name, [mopath % name])) | ||
218 | 187 | |||
219 | 188 | if sys.argv[1] == "clean": | ||
220 | 189 | try: | ||
221 | 190 | os.remove ("data/indicator/specto") | ||
222 | 191 | os.remove ("specto.desktop") | ||
223 | 192 | except: | ||
224 | 193 | pass | ||
225 | 189 | 194 | ||
226 | 190 | 195 | ||
227 | 191 | setup(name = "specto", | 196 | setup(name = "specto", |
228 | @@ -202,13 +207,9 @@ | |||
229 | 202 | "install_data" : install_data} | 207 | "install_data" : install_data} |
230 | 203 | ) | 208 | ) |
231 | 204 | 209 | ||
232 | 205 | os.remove ("spectlib/constants.py") | ||
233 | 206 | os.remove ("data/indicator/specto") | ||
234 | 207 | os.remove ("specto.desktop") | ||
235 | 208 | |||
236 | 209 | if sys.argv[1] == "install": | 210 | if sys.argv[1] == "install": |
239 | 210 | gtk_update_icon_cache = '''gtk-update-icon-cache -f -t \ | 211 | gtk_update_icon_cache = "gtk-update-icon-cache -f -t \ |
240 | 211 | %s/share/icons/hicolor''' % prefix | 212 | %s/share/icons/hicolor" % prefix |
241 | 212 | root_specified = len (filter (lambda s: s.startswith ("--root"), | 213 | root_specified = len (filter (lambda s: s.startswith ("--root"), |
242 | 213 | sys.argv)) > 0 | 214 | sys.argv)) > 0 |
243 | 214 | if not root_specified: | 215 | if not root_specified: |
244 | 215 | 216 | ||
245 | === modified file 'spectlib/__init__.py' | |||
246 | --- spectlib/__init__.py 2006-12-17 03:53:01 +0000 | |||
247 | +++ spectlib/__init__.py 2011-08-10 10:01:36 +0000 | |||
248 | @@ -0,0 +1,3 @@ | |||
249 | 1 | |||
250 | 2 | __pkg_name__ = 'specto' | ||
251 | 3 | __pkg_version__ = '0.4.1' | ||
252 | 0 | 4 | ||
253 | === removed file 'spectlib/constants.py.in' | |||
254 | --- spectlib/constants.py.in 2010-11-23 14:32:32 +0000 | |||
255 | +++ spectlib/constants.py.in 1970-01-01 00:00:00 +0000 | |||
256 | @@ -1,7 +0,0 @@ | |||
257 | 1 | # -*- coding: utf-8 -*- | ||
258 | 2 | |||
259 | 3 | # The Specto version | ||
260 | 4 | VERSION = "@version@" | ||
261 | 5 | |||
262 | 6 | # The prefix were Specto is installed to. | ||
263 | 7 | PREFIX = "@prefix@" | ||
264 | 8 | 0 | ||
265 | === modified file 'spectlib/i18n.py' | |||
266 | --- spectlib/i18n.py 2010-11-23 15:28:11 +0000 | |||
267 | +++ spectlib/i18n.py 2011-08-10 10:01:36 +0000 | |||
268 | @@ -25,13 +25,13 @@ | |||
269 | 25 | import gettext | 25 | import gettext |
270 | 26 | import locale | 26 | import locale |
271 | 27 | 27 | ||
273 | 28 | # If Specto is installed read prefix from constants module | 28 | |
274 | 29 | MESSAGES_DIR = '' | 29 | MESSAGES_DIR = '' |
280 | 30 | try: | 30 | if os.path.exists("/usr/share/locale") and os.path.isdir("/usr/share/locale"): |
281 | 31 | from spectlib.constants import PREFIX | 31 | MESSAGES_DIR = "/usr/share/locale" |
282 | 32 | MESSAGES_DIR = "%s/share/locale" % PREFIX | 32 | elif os.path.exists("/usr/local/share/locale") and \ |
283 | 33 | except ImportError: | 33 | os.path.isdir("/usr/local/share/locale"): |
284 | 34 | pass | 34 | MESSAGES_DIR = "/usr/local/share/locale" |
285 | 35 | 35 | ||
286 | 36 | def setup_locale_and_gettext(): | 36 | def setup_locale_and_gettext(): |
287 | 37 | package_name = 'specto' | 37 | package_name = 'specto' |
288 | 38 | 38 | ||
289 | === modified file 'spectlib/main.py' | |||
290 | --- spectlib/main.py 2011-06-23 15:23:11 +0000 | |||
291 | +++ spectlib/main.py 2011-08-10 10:01:36 +0000 | |||
292 | @@ -45,12 +45,7 @@ | |||
293 | 45 | from spectlib.tools import networkmanager as conmgr | 45 | from spectlib.tools import networkmanager as conmgr |
294 | 46 | 46 | ||
295 | 47 | 47 | ||
302 | 48 | VERSION = "undefined" | 48 | from spectlib import __pkg_version__ as VERSION |
297 | 49 | try: | ||
298 | 50 | from spectlib.constants import VERSION | ||
299 | 51 | except ImportError: | ||
300 | 52 | with open("VERSION", 'r') as version_file: | ||
301 | 53 | VERSION = version_file.read().strip() | ||
303 | 54 | 49 | ||
304 | 55 | #create a gconf object | 50 | #create a gconf object |
305 | 56 | specto_gconf = Specto_gconf("/apps/specto") | 51 | specto_gconf = Specto_gconf("/apps/specto") |
306 | 57 | 52 | ||
307 | === modified file 'spectlib/util.py' | |||
308 | --- spectlib/util.py 2010-11-23 16:19:28 +0000 | |||
309 | +++ spectlib/util.py 2011-08-10 10:01:36 +0000 | |||
310 | @@ -26,11 +26,12 @@ | |||
311 | 26 | 26 | ||
312 | 27 | from spectlib.tools.specto_gconf import Specto_gconf | 27 | from spectlib.tools.specto_gconf import Specto_gconf |
313 | 28 | 28 | ||
314 | 29 | |||
315 | 29 | PREFIX = '' | 30 | PREFIX = '' |
320 | 30 | try: | 31 | if os.path.exists("/usr") and os.path.isdir("/usr"): |
321 | 31 | from spectlib.constants import PREFIX | 32 | PREFIX = "/usr" |
322 | 32 | except ImportError: | 33 | elif os.path.exists("/usr/local") and os.path.isdir("/usr/local"): |
323 | 33 | pass | 34 | PREFIX = "/usr/local" |
324 | 34 | 35 | ||
325 | 35 | def return_webpage(webpage): | 36 | def return_webpage(webpage): |
326 | 36 | """ Open the webpage in the default browser. """ | 37 | """ Open the webpage in the default browser. """ |
After uncompressing the tarball resulting from "python setup.py sdist", "sudo setup.py install" fails like so:
running install_scripts 2.7/specto -> /usr/bin
copying build/scripts-
changing mode of /usr/bin/specto to 755
running install_data
error: can't copy 'specto.desktop': doesn't exist or not a regular file
Then when you try to run "sudo python setup.py uninstall", you get:
warning: uninstall: Could not read installed files list installed_files