Merge lp:~frgomes/setuptoolsbzr/lp1254288 into lp:setuptoolsbzr
- lp1254288
- Merge into devel
Proposed by
Richard Gomes
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Richard Gomes | ||||||||
Approved revision: | 24 | ||||||||
Merged at revision: | 16 | ||||||||
Proposed branch: | lp:~frgomes/setuptoolsbzr/lp1254288 | ||||||||
Merge into: | lp:setuptoolsbzr | ||||||||
Diff against target: |
376 lines (+46/-248) 4 files modified
README.txt (+1/-0) ez_setup.py (+0/-228) setup.py (+21/-8) setuptools_bzr/__init__.py (+24/-12) |
||||||||
To merge this branch: | bzr merge lp:~frgomes/setuptoolsbzr/lp1254288 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Richard Gomes | Pending | ||
Review via email: mp+201116@code.launchpad.net |
Commit message
Merged with branch: ~frgomes/
Description of the change
Merge for release 2.2
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 | === modified file 'README.txt' | |||
2 | --- README.txt 2008-04-02 21:24:27 +0000 | |||
3 | +++ README.txt 2014-01-09 22:49:08 +0000 | |||
4 | @@ -57,6 +57,7 @@ | |||
5 | 57 | =================== | 57 | =================== |
6 | 58 | 58 | ||
7 | 59 | Author: Barry Warsaw <barry@python.org> | 59 | Author: Barry Warsaw <barry@python.org> |
8 | 60 | Maintainer: Richard Gomes <rgomes.info@gmail.com> | ||
9 | 60 | 61 | ||
10 | 61 | This package is developed on Launchpad_. Please see the `project page`_ for | 62 | This package is developed on Launchpad_. Please see the `project page`_ for |
11 | 62 | submitting bug reports. | 63 | submitting bug reports. |
12 | 63 | 64 | ||
13 | === removed file 'ez_setup.py' | |||
14 | --- ez_setup.py 2007-07-20 23:02:07 +0000 | |||
15 | +++ ez_setup.py 1970-01-01 00:00:00 +0000 | |||
16 | @@ -1,228 +0,0 @@ | |||
17 | 1 | #!python | ||
18 | 2 | """Bootstrap setuptools installation | ||
19 | 3 | |||
20 | 4 | If you want to use setuptools in your package's setup.py, just include this | ||
21 | 5 | file in the same directory with it, and add this to the top of your setup.py:: | ||
22 | 6 | |||
23 | 7 | from ez_setup import use_setuptools | ||
24 | 8 | use_setuptools() | ||
25 | 9 | |||
26 | 10 | If you want to require a specific version of setuptools, set a download | ||
27 | 11 | mirror, or use an alternate download directory, you can do so by supplying | ||
28 | 12 | the appropriate options to ``use_setuptools()``. | ||
29 | 13 | |||
30 | 14 | This file can also be run as a script to install or upgrade setuptools. | ||
31 | 15 | """ | ||
32 | 16 | import sys | ||
33 | 17 | DEFAULT_VERSION = "0.6c5" | ||
34 | 18 | DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] | ||
35 | 19 | |||
36 | 20 | md5_data = { | ||
37 | 21 | 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', | ||
38 | 22 | 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', | ||
39 | 23 | 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', | ||
40 | 24 | 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', | ||
41 | 25 | 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', | ||
42 | 26 | 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', | ||
43 | 27 | 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', | ||
44 | 28 | 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', | ||
45 | 29 | 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', | ||
46 | 30 | 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', | ||
47 | 31 | 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', | ||
48 | 32 | 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', | ||
49 | 33 | 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', | ||
50 | 34 | 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', | ||
51 | 35 | 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', | ||
52 | 36 | 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', | ||
53 | 37 | 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', | ||
54 | 38 | 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', | ||
55 | 39 | 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', | ||
56 | 40 | 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', | ||
57 | 41 | 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', | ||
58 | 42 | } | ||
59 | 43 | |||
60 | 44 | import sys, os | ||
61 | 45 | |||
62 | 46 | def _validate_md5(egg_name, data): | ||
63 | 47 | if egg_name in md5_data: | ||
64 | 48 | from md5 import md5 | ||
65 | 49 | digest = md5(data).hexdigest() | ||
66 | 50 | if digest != md5_data[egg_name]: | ||
67 | 51 | print >>sys.stderr, ( | ||
68 | 52 | "md5 validation of %s failed! (Possible download problem?)" | ||
69 | 53 | % egg_name | ||
70 | 54 | ) | ||
71 | 55 | sys.exit(2) | ||
72 | 56 | return data | ||
73 | 57 | |||
74 | 58 | |||
75 | 59 | def use_setuptools( | ||
76 | 60 | version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, | ||
77 | 61 | download_delay=15 | ||
78 | 62 | ): | ||
79 | 63 | """Automatically find/download setuptools and make it available on sys.path | ||
80 | 64 | |||
81 | 65 | `version` should be a valid setuptools version number that is available | ||
82 | 66 | as an egg for download under the `download_base` URL (which should end with | ||
83 | 67 | a '/'). `to_dir` is the directory where setuptools will be downloaded, if | ||
84 | 68 | it is not already available. If `download_delay` is specified, it should | ||
85 | 69 | be the number of seconds that will be paused before initiating a download, | ||
86 | 70 | should one be required. If an older version of setuptools is installed, | ||
87 | 71 | this routine will print a message to ``sys.stderr`` and raise SystemExit in | ||
88 | 72 | an attempt to abort the calling script. | ||
89 | 73 | """ | ||
90 | 74 | try: | ||
91 | 75 | import setuptools | ||
92 | 76 | if setuptools.__version__ == '0.0.1': | ||
93 | 77 | print >>sys.stderr, ( | ||
94 | 78 | "You have an obsolete version of setuptools installed. Please\n" | ||
95 | 79 | "remove it from your system entirely before rerunning this script." | ||
96 | 80 | ) | ||
97 | 81 | sys.exit(2) | ||
98 | 82 | except ImportError: | ||
99 | 83 | egg = download_setuptools(version, download_base, to_dir, download_delay) | ||
100 | 84 | sys.path.insert(0, egg) | ||
101 | 85 | import setuptools; setuptools.bootstrap_install_from = egg | ||
102 | 86 | |||
103 | 87 | import pkg_resources | ||
104 | 88 | try: | ||
105 | 89 | pkg_resources.require("setuptools>="+version) | ||
106 | 90 | |||
107 | 91 | except pkg_resources.VersionConflict, e: | ||
108 | 92 | # XXX could we install in a subprocess here? | ||
109 | 93 | print >>sys.stderr, ( | ||
110 | 94 | "The required version of setuptools (>=%s) is not available, and\n" | ||
111 | 95 | "can't be installed while this script is running. Please install\n" | ||
112 | 96 | " a more recent version first.\n\n(Currently using %r)" | ||
113 | 97 | ) % (version, e.args[0]) | ||
114 | 98 | sys.exit(2) | ||
115 | 99 | |||
116 | 100 | def download_setuptools( | ||
117 | 101 | version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, | ||
118 | 102 | delay = 15 | ||
119 | 103 | ): | ||
120 | 104 | """Download setuptools from a specified location and return its filename | ||
121 | 105 | |||
122 | 106 | `version` should be a valid setuptools version number that is available | ||
123 | 107 | as an egg for download under the `download_base` URL (which should end | ||
124 | 108 | with a '/'). `to_dir` is the directory where the egg will be downloaded. | ||
125 | 109 | `delay` is the number of seconds to pause before an actual download attempt. | ||
126 | 110 | """ | ||
127 | 111 | import urllib2, shutil | ||
128 | 112 | egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) | ||
129 | 113 | url = download_base + egg_name | ||
130 | 114 | saveto = os.path.join(to_dir, egg_name) | ||
131 | 115 | src = dst = None | ||
132 | 116 | if not os.path.exists(saveto): # Avoid repeated downloads | ||
133 | 117 | try: | ||
134 | 118 | from distutils import log | ||
135 | 119 | if delay: | ||
136 | 120 | log.warn(""" | ||
137 | 121 | --------------------------------------------------------------------------- | ||
138 | 122 | This script requires setuptools version %s to run (even to display | ||
139 | 123 | help). I will attempt to download it for you (from | ||
140 | 124 | %s), but | ||
141 | 125 | you may need to enable firewall access for this script first. | ||
142 | 126 | I will start the download in %d seconds. | ||
143 | 127 | |||
144 | 128 | (Note: if this machine does not have network access, please obtain the file | ||
145 | 129 | |||
146 | 130 | %s | ||
147 | 131 | |||
148 | 132 | and place it in this directory before rerunning this script.) | ||
149 | 133 | ---------------------------------------------------------------------------""", | ||
150 | 134 | version, download_base, delay, url | ||
151 | 135 | ); from time import sleep; sleep(delay) | ||
152 | 136 | log.warn("Downloading %s", url) | ||
153 | 137 | src = urllib2.urlopen(url) | ||
154 | 138 | # Read/write all in one block, so we don't create a corrupt file | ||
155 | 139 | # if the download is interrupted. | ||
156 | 140 | data = _validate_md5(egg_name, src.read()) | ||
157 | 141 | dst = open(saveto,"wb"); dst.write(data) | ||
158 | 142 | finally: | ||
159 | 143 | if src: src.close() | ||
160 | 144 | if dst: dst.close() | ||
161 | 145 | return os.path.realpath(saveto) | ||
162 | 146 | |||
163 | 147 | def main(argv, version=DEFAULT_VERSION): | ||
164 | 148 | """Install or upgrade setuptools and EasyInstall""" | ||
165 | 149 | |||
166 | 150 | try: | ||
167 | 151 | import setuptools | ||
168 | 152 | except ImportError: | ||
169 | 153 | egg = None | ||
170 | 154 | try: | ||
171 | 155 | egg = download_setuptools(version, delay=0) | ||
172 | 156 | sys.path.insert(0,egg) | ||
173 | 157 | from setuptools.command.easy_install import main | ||
174 | 158 | return main(list(argv)+[egg]) # we're done here | ||
175 | 159 | finally: | ||
176 | 160 | if egg and os.path.exists(egg): | ||
177 | 161 | os.unlink(egg) | ||
178 | 162 | else: | ||
179 | 163 | if setuptools.__version__ == '0.0.1': | ||
180 | 164 | # tell the user to uninstall obsolete version | ||
181 | 165 | use_setuptools(version) | ||
182 | 166 | |||
183 | 167 | req = "setuptools>="+version | ||
184 | 168 | import pkg_resources | ||
185 | 169 | try: | ||
186 | 170 | pkg_resources.require(req) | ||
187 | 171 | except pkg_resources.VersionConflict: | ||
188 | 172 | try: | ||
189 | 173 | from setuptools.command.easy_install import main | ||
190 | 174 | except ImportError: | ||
191 | 175 | from easy_install import main | ||
192 | 176 | main(list(argv)+[download_setuptools(delay=0)]) | ||
193 | 177 | sys.exit(0) # try to force an exit | ||
194 | 178 | else: | ||
195 | 179 | if argv: | ||
196 | 180 | from setuptools.command.easy_install import main | ||
197 | 181 | main(argv) | ||
198 | 182 | else: | ||
199 | 183 | print "Setuptools version",version,"or greater has been installed." | ||
200 | 184 | print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' | ||
201 | 185 | |||
202 | 186 | |||
203 | 187 | |||
204 | 188 | def update_md5(filenames): | ||
205 | 189 | """Update our built-in md5 registry""" | ||
206 | 190 | |||
207 | 191 | import re | ||
208 | 192 | from md5 import md5 | ||
209 | 193 | |||
210 | 194 | for name in filenames: | ||
211 | 195 | base = os.path.basename(name) | ||
212 | 196 | f = open(name,'rb') | ||
213 | 197 | md5_data[base] = md5(f.read()).hexdigest() | ||
214 | 198 | f.close() | ||
215 | 199 | |||
216 | 200 | data = [" %r: %r,\n" % it for it in md5_data.items()] | ||
217 | 201 | data.sort() | ||
218 | 202 | repl = "".join(data) | ||
219 | 203 | |||
220 | 204 | import inspect | ||
221 | 205 | srcfile = inspect.getsourcefile(sys.modules[__name__]) | ||
222 | 206 | f = open(srcfile, 'rb'); src = f.read(); f.close() | ||
223 | 207 | |||
224 | 208 | match = re.search("\nmd5_data = {\n([^}]+)}", src) | ||
225 | 209 | if not match: | ||
226 | 210 | print >>sys.stderr, "Internal error!" | ||
227 | 211 | sys.exit(2) | ||
228 | 212 | |||
229 | 213 | src = src[:match.start(1)] + repl + src[match.end(1):] | ||
230 | 214 | f = open(srcfile,'w') | ||
231 | 215 | f.write(src) | ||
232 | 216 | f.close() | ||
233 | 217 | |||
234 | 218 | |||
235 | 219 | if __name__=='__main__': | ||
236 | 220 | if len(sys.argv)>2 and sys.argv[1]=='--md5update': | ||
237 | 221 | update_md5(sys.argv[2:]) | ||
238 | 222 | else: | ||
239 | 223 | main(sys.argv[1:]) | ||
240 | 224 | |||
241 | 225 | |||
242 | 226 | |||
243 | 227 | |||
244 | 228 | |||
245 | 229 | 0 | ||
246 | === modified file 'setup.py' | |||
247 | --- setup.py 2010-11-04 20:23:07 +0000 | |||
248 | +++ setup.py 2014-01-09 22:49:08 +0000 | |||
249 | @@ -15,10 +15,6 @@ | |||
250 | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
251 | 16 | # USA. | 16 | # USA. |
252 | 17 | 17 | ||
253 | 18 | |||
254 | 19 | import ez_setup | ||
255 | 20 | ez_setup.use_setuptools() | ||
256 | 21 | |||
257 | 22 | from setuptools import setup, find_packages | 18 | from setuptools import setup, find_packages |
258 | 23 | from setuptools_bzr import __version__ | 19 | from setuptools_bzr import __version__ |
259 | 24 | 20 | ||
260 | @@ -29,17 +25,34 @@ | |||
261 | 29 | description = 'setuptools plugin for bzr', | 25 | description = 'setuptools plugin for bzr', |
262 | 30 | author = 'Barry Warsaw', | 26 | author = 'Barry Warsaw', |
263 | 31 | author_email = 'barry@python.org', | 27 | author_email = 'barry@python.org', |
264 | 28 | maintainer = 'Richard Gomes', | ||
265 | 29 | maintainer_email= 'rgomes.info@gmail.com', | ||
266 | 32 | license = 'LGPLv3', | 30 | license = 'LGPLv3', |
267 | 33 | # For historical reasons, the code lives under a different project name. | 31 | # For historical reasons, the code lives under a different project name. |
268 | 34 | url = 'https://launchpad.net/setuptoolsbzr', | 32 | url = 'https://launchpad.net/setuptoolsbzr', |
270 | 35 | keywords = 'distutils setuptools setup', | 33 | keywords = 'distutils setuptools setup bzr bazaar', |
271 | 36 | packages = find_packages(), | 34 | packages = find_packages(), |
272 | 35 | classifiers=[ | ||
273 | 36 | "Development Status :: 5 - Production/Stable", | ||
274 | 37 | "Programming Language :: Python", | ||
275 | 38 | "Programming Language :: Python :: 2", | ||
276 | 39 | "Programming Language :: Python :: 2.4", | ||
277 | 40 | "Programming Language :: Python :: 2.5", | ||
278 | 41 | "Programming Language :: Python :: 2.6", | ||
279 | 42 | "Programming Language :: Python :: 2.7", | ||
280 | 43 | "Programming Language :: Python :: 3", | ||
281 | 44 | "Programming Language :: Python :: 3.1", | ||
282 | 45 | "Programming Language :: Python :: 3.2", | ||
283 | 46 | "Programming Language :: Python :: 3.3", | ||
284 | 47 | "Intended Audience :: Developers", | ||
285 | 48 | "Operating System :: OS Independent", | ||
286 | 49 | "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", | ||
287 | 50 | "Topic :: Software Development :: Version Control", | ||
288 | 51 | "Framework :: Setuptools Plugin", | ||
289 | 52 | ], | ||
290 | 37 | entry_points = { | 53 | entry_points = { |
291 | 38 | 'setuptools.file_finders': [ | 54 | 'setuptools.file_finders': [ |
292 | 39 | 'bzr = setuptools_bzr:find_files_for_bzr', | 55 | 'bzr = setuptools_bzr:find_files_for_bzr', |
293 | 40 | ], | 56 | ], |
294 | 41 | }, | 57 | }, |
295 | 42 | install_requires = { | ||
296 | 43 | 'bzr': ['bzr'], | ||
297 | 44 | }, | ||
298 | 45 | ) | 58 | ) |
299 | 46 | 59 | ||
300 | === modified file 'setuptools_bzr/__init__.py' | |||
301 | --- setuptools_bzr/__init__.py 2010-11-04 20:23:07 +0000 | |||
302 | +++ setuptools_bzr/__init__.py 2014-01-09 22:49:08 +0000 | |||
303 | @@ -15,15 +15,17 @@ | |||
304 | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
305 | 16 | # USA. | 16 | # USA. |
306 | 17 | 17 | ||
307 | 18 | from __future__ import print_function | ||
308 | 19 | |||
309 | 18 | """setuptools plugin for projects maintained under Bazaar.""" | 20 | """setuptools plugin for projects maintained under Bazaar.""" |
310 | 19 | 21 | ||
312 | 20 | __version__ = '2.1' | 22 | __version__ = '2.2' |
313 | 21 | __all__ = [ | 23 | __all__ = [ |
314 | 22 | 'find_files_for_bzr', | 24 | 'find_files_for_bzr', |
315 | 23 | ] | 25 | ] |
316 | 24 | 26 | ||
317 | 25 | 27 | ||
319 | 26 | import os | 28 | import os, sys |
320 | 27 | import subprocess | 29 | import subprocess |
321 | 28 | 30 | ||
322 | 29 | try: | 31 | try: |
323 | @@ -34,6 +36,9 @@ | |||
324 | 34 | Branch = None | 36 | Branch = None |
325 | 35 | 37 | ||
326 | 36 | 38 | ||
327 | 39 | PY3 = sys.version[0] == "3" | ||
328 | 40 | |||
329 | 41 | |||
330 | 37 | if os.getenv('BZR_SETUPTOOLS_FORCE_CMD'): | 42 | if os.getenv('BZR_SETUPTOOLS_FORCE_CMD'): |
331 | 38 | Branch = None | 43 | Branch = None |
332 | 39 | 44 | ||
333 | @@ -47,11 +52,11 @@ | |||
334 | 47 | branch.lock_read() | 52 | branch.lock_read() |
335 | 48 | try: | 53 | try: |
336 | 49 | # Get the inventory of the branch's last revision. | 54 | # Get the inventory of the branch's last revision. |
338 | 50 | inv = branch.repository.get_revision_inventory(branch.last_revision()) | 55 | inv = branch.repository.get_inventory(branch.last_revision()) |
339 | 51 | # Get the inventory entry for the path. | 56 | # Get the inventory entry for the path. |
340 | 52 | entry = inv[inv.path2id(path)] | 57 | entry = inv[inv.path2id(path)] |
341 | 53 | # Return the names of the children. | 58 | # Return the names of the children. |
343 | 54 | return [os.path.join(path, child) for child in entry.children.keys()] | 59 | return [os.path.join(path, child) for child in list(entry.children.keys())] |
344 | 55 | finally: | 60 | finally: |
345 | 56 | branch.unlock() | 61 | branch.unlock() |
346 | 57 | 62 | ||
347 | @@ -76,14 +81,21 @@ | |||
348 | 76 | 81 | ||
349 | 77 | def bzr_find_files_for_bzr(dirname): | 82 | def bzr_find_files_for_bzr(dirname): |
350 | 78 | """Use the program bzr(1) to recursively find versioned files.""" | 83 | """Use the program bzr(1) to recursively find versioned files.""" |
359 | 79 | cmd = 'bzr ls --versioned ' + dirname | 84 | cmd = 'bzr ls --recursive --versioned ' + dirname |
360 | 80 | proc = subprocess.Popen(cmd.split(), | 85 | try: |
361 | 81 | stdin=subprocess.PIPE, | 86 | proc = subprocess.Popen(cmd.split(), |
362 | 82 | stdout=subprocess.PIPE, | 87 | stdin=subprocess.PIPE, |
363 | 83 | stderr=subprocess.PIPE) | 88 | stdout=subprocess.PIPE, |
364 | 84 | stdout, stderr = proc.communicate() | 89 | stderr=subprocess.PIPE) |
365 | 85 | # XXX check for errors and log stderr | 90 | stdout, stderr = proc.communicate() |
366 | 86 | return stdout.splitlines() | 91 | except Exception as e: |
367 | 92 | print('WARNING: bzr: {}'.format(e), file=sys.stderr) | ||
368 | 93 | return [] | ||
369 | 94 | |||
370 | 95 | if not PY3: | ||
371 | 96 | return stdout.splitlines() | ||
372 | 97 | else: | ||
373 | 98 | return (line.decode('utf-8') for line in stdout.splitlines()) | ||
374 | 87 | 99 | ||
375 | 88 | 100 | ||
376 | 89 | def find_files_for_bzr(dirname): | 101 | def find_files_for_bzr(dirname): |