Merge lp:~gary/zc.buildout/python-support-1-cleanup into lp:zc.buildout

Proposed by Gary Poster
Status: Needs review
Proposed branch: lp:~gary/zc.buildout/python-support-1-cleanup
Merge into: lp:zc.buildout
Diff against target: 296 lines (+36/-30)
9 files modified
README.txt (+1/-1)
src/zc/buildout/easy_install.py (+5/-5)
src/zc/buildout/testing.py (+6/-2)
src/zc/buildout/tests.py (+2/-1)
zc.recipe.egg_/src/zc/recipe/egg/README.txt (+2/-2)
zc.recipe.egg_/src/zc/recipe/egg/api.txt (+4/-3)
zc.recipe.egg_/src/zc/recipe/egg/custom.txt (+9/-9)
zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt (+3/-3)
zc.recipe.egg_/src/zc/recipe/egg/tests.py (+4/-4)
To merge this branch: bzr merge lp:~gary/zc.buildout/python-support-1-cleanup
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) Approve
Review via email: mp+19532@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

This branch does three simple things.

- It fixes a few typos.

- It removes a bit of trailing whitespace.

- It makes a test result a bit more robust on Windows.

These changes are extracted out of the rest of the branches for python-support to try and simplify the review.

538. By Gary Poster

merge from trunk

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

> === modified file 'src/zc/buildout/testing.py'
> --- src/zc/buildout/testing.py 2009-11-06 22:33:23 +0000
> +++ src/zc/buildout/testing.py 2010-02-17 21:22:11 +0000
> @@ -492,10 +492,14 @@
> path = path[1:]
> return '/' + path.replace(os.path.sep, '/')
>
> +if sys.platform == 'win32':
> + sep = r'[\\/]' # Windows uses both sometimes.
> +else:
> + sep = re.escape(os.path.sep)
> normalize_path = (
> re.compile(
> - r'''[^'" \t\n\r]+\%(sep)s_[Tt][Ee][Ss][Tt]_\%(sep)s([^"' \t\n\r]+)'''
> - % dict(sep=os.path.sep)),
> + r'''[^'" \t\n\r]+%(sep)s_[Tt][Ee][Ss][Tt]_%(sep)s([^"' \t\n\r]+)'''
> + % dict(sep=sep)),
> _normalize_path,
> )

I don't understand why you removed the backslash from the normalize_path
regex. IS it that you want the backslash to be a separator only on windows?

Rest looks good.

review: Approve
Revision history for this message
Gary Poster (gary) wrote :

Thank you!

I didn't remove the backslash--I switched to using re.escape (for non-Windows). The backslash I removed was escaping the path separator.

For Windows, then, the result will be this.

[^'" \t\n\r]+[\\/]_[Tt][Ee][Ss][Tt]_[\\/]([^"' \t\n\r]+)

IOW, the path separator might be a backslash (Windows path) or a forward slash (typically when it is a URI).

For everything else (if we assume that everything else uses a forward slash for path separators), it will *continue* to be the following, at least effectively (forward slashes actually don't need to be escaped, IIRC, so re.escape won't do anything, and the backslashes didn't do anything before).

[^'" \t\n\r]+/_[Tt][Ee][Ss][Tt]_/([^"' \t\n\r]+)

Actually, now that I think of it, a better change would be this:

sep = os.path.sep
if sep != "/":
    sep = r'[%s/]' % re.escape(sep) # May be a path or a URI\
...
and then the compilation

Unmerged revisions

538. By Gary Poster

merge from trunk

537. By gary

the whitespace-police, the typo-police, the grammar police, and the Windows testing police all joined together for this check-in of mostly trivial changes.

536. By gary

another typo branch

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 2010-01-08 05:54:43 +0000
3+++ README.txt 2010-02-17 21:22:11 +0000
4@@ -126,7 +126,7 @@
5 `--version` option of the bootstrap.py script::
6
7 $ python bootstrap.py --version 1.1.3
8-
9+
10 The `zc.buildout project <http://svn.zope.org/zc.buildout/trunk>`_
11 is a slightly more complex example of this type of buildout.
12
13
14=== modified file 'src/zc/buildout/easy_install.py'
15--- src/zc/buildout/easy_install.py 2009-11-11 21:21:11 +0000
16+++ src/zc/buildout/easy_install.py 2010-02-17 21:22:11 +0000
17@@ -495,7 +495,7 @@
18
19 if dist is None:
20 raise zc.buildout.UserError(
21- "Couln't download distribution %s." % avail)
22+ "Couldn't download distribution %s." % avail)
23
24 if dist.precedence == pkg_resources.EGG_DIST:
25 # It's already an egg, just fetch it into the dest
26@@ -628,9 +628,9 @@
27 logger.debug('Installing %s.', repr(specs)[1:-1])
28
29 path = self._path
30- dest = self._dest
31- if dest is not None and dest not in path:
32- path.insert(0, dest)
33+ destination = self._dest
34+ if destination is not None and destination not in path:
35+ path.insert(0, destination)
36
37 requirements = [self._constrain(pkg_resources.Requirement.parse(spec))
38 for spec in specs]
39@@ -661,7 +661,7 @@
40 except pkg_resources.DistributionNotFound, err:
41 [requirement] = err
42 requirement = self._constrain(requirement)
43- if dest:
44+ if destination:
45 logger.debug('Getting required %r', str(requirement))
46 else:
47 logger.debug('Adding required %r', str(requirement))
48
49=== modified file 'src/zc/buildout/testing.py'
50--- src/zc/buildout/testing.py 2009-11-06 22:33:23 +0000
51+++ src/zc/buildout/testing.py 2010-02-17 21:22:11 +0000
52@@ -492,10 +492,14 @@
53 path = path[1:]
54 return '/' + path.replace(os.path.sep, '/')
55
56+if sys.platform == 'win32':
57+ sep = r'[\\/]' # Windows uses both sometimes.
58+else:
59+ sep = re.escape(os.path.sep)
60 normalize_path = (
61 re.compile(
62- r'''[^'" \t\n\r]+\%(sep)s_[Tt][Ee][Ss][Tt]_\%(sep)s([^"' \t\n\r]+)'''
63- % dict(sep=os.path.sep)),
64+ r'''[^'" \t\n\r]+%(sep)s_[Tt][Ee][Ss][Tt]_%(sep)s([^"' \t\n\r]+)'''
65+ % dict(sep=sep)),
66 _normalize_path,
67 )
68
69
70=== modified file 'src/zc/buildout/tests.py'
71--- src/zc/buildout/tests.py 2009-11-11 21:21:11 +0000
72+++ src/zc/buildout/tests.py 2010-02-17 21:22:11 +0000
73@@ -2880,7 +2880,7 @@
74 'We have a develop egg: zc.buildout X.X.'),
75 (re.compile(r'\\[\\]?'), '/'),
76 (re.compile('WindowsError'), 'OSError'),
77- (re.compile(r'\[Error 17\] Cannot create a file '
78+ (re.compile(r'\[Error \d+\] Cannot create a file '
79 r'when that file already exists: '),
80 '[Errno 17] File exists: '
81 ),
82@@ -2933,6 +2933,7 @@
83 (re.compile('extdemo[.]pyd'), 'extdemo.so'),
84 (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
85 (re.compile(r'\\[\\]?'), '/'),
86+ (re.compile(r'\#!\S+\bpython\S*'), '#!/usr/bin/python'),
87 ]+(sys.version_info < (2, 5) and [
88 (re.compile('.*No module named runpy.*', re.S), ''),
89 (re.compile('.*usage: pdb.py scriptfile .*', re.S), ''),
90
91=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/README.txt'
92--- zc.recipe.egg_/src/zc/recipe/egg/README.txt 2009-11-06 22:33:23 +0000
93+++ zc.recipe.egg_/src/zc/recipe/egg/README.txt 2010-02-17 21:22:11 +0000
94@@ -46,7 +46,7 @@
95 <a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
96 </body></html>
97
98-We have a sample buildout. Let's update it's configuration file to
99+We have a sample buildout. Let's update its configuration file to
100 install the demo package.
101
102 >>> write(sample_buildout, 'buildout.cfg',
103@@ -187,7 +187,7 @@
104 ... interpreter = py-demo
105 ... """ % dict(server=link_server))
106
107-Note that we ommitted the entry point name from the recipe
108+Note that we omitted the entry point name from the recipe
109 specification. We were able to do this because the scripts recipe is
110 the default entry point for the zc.recipe.egg egg.
111
112
113=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/api.txt'
114--- zc.recipe.egg_/src/zc/recipe/egg/api.txt 2008-07-15 23:09:58 +0000
115+++ zc.recipe.egg_/src/zc/recipe/egg/api.txt 2010-02-17 21:22:11 +0000
116@@ -15,7 +15,7 @@
117 around the egg recipe:
118
119 >>> mkdir(sample_buildout, 'sample')
120- >>> write(sample_buildout, 'sample', 'sample.py',
121+ >>> write(sample_buildout, 'sample', 'sample.py',
122 ... """
123 ... import logging, os
124 ... import zc.recipe.egg
125@@ -53,7 +53,7 @@
126 >>> write(sample_buildout, 'sample', 'setup.py',
127 ... """
128 ... from setuptools import setup
129- ...
130+ ...
131 ... setup(
132 ... name = "sample",
133 ... entry_points = {'zc.buildout': ['default = sample:Sample']},
134@@ -95,12 +95,13 @@
135 computed by the egg recipe by looking at .installed.cfg:
136
137 >>> cat(sample_buildout, '.installed.cfg')
138+ ... # doctest: +NORMALIZE_WHITESPACE
139 [buildout]
140 installed_develop_eggs = /sample-buildout/develop-eggs/sample.egg-link
141 parts = sample-part
142 <BLANKLINE>
143 [sample-part]
144- __buildout_installed__ =
145+ __buildout_installed__ =
146 __buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
147 zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==
148 setuptools-0.6-py2.4.egg
149
150=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/custom.txt'
151--- zc.recipe.egg_/src/zc/recipe/egg/custom.txt 2008-08-27 06:48:40 +0000
152+++ zc.recipe.egg_/src/zc/recipe/egg/custom.txt 2010-02-17 21:22:11 +0000
153@@ -50,7 +50,7 @@
154 swig
155 The path to the swig executable
156
157-swig-cpp
158+swig-cpp
159 Make SWIG create C++ files (default is C)
160
161 swig-opts
162@@ -73,14 +73,14 @@
163 alternate index with this option. If you use the links option and
164 if the links point to the needed distributions, then the index can
165 be anything and will be largely ignored. In the examples, here,
166- we'll just point to an empty directory on our link server. This
167+ we'll just point to an empty directory on our link server. This
168 will make our examples run a little bit faster.
169
170 python
171 The name of a section to get the Python executable from.
172 If not specified, then the buildout python option is used. The
173 Python executable is found in the executable option of the named
174- section.
175+ section.
176
177 environment
178 The name of a section with additional environment variables. The
179@@ -188,7 +188,7 @@
180 ...
181 ... [demo]
182 ... recipe = zc.recipe.egg
183- ... eggs = demo
184+ ... eggs = demo
185 ... extdemo
186 ... entry-points = demo=demo:main
187 ... """ % dict(server=link_server))
188@@ -270,7 +270,7 @@
189 ...
190 ... [demo]
191 ... recipe = zc.recipe.egg
192- ... eggs = demo
193+ ... eggs = demo
194 ... extdemo ==1.4
195 ... entry-points = demo=demo:main
196 ... """ % dict(server=link_server))
197@@ -440,7 +440,7 @@
198 Uninstalling extdemo.
199 Installing extdemo.
200 zip_safe flag not set; analyzing archive contents...
201-
202+
203 >>> rmdir(sample_buildout, 'recipes')
204
205
206@@ -496,7 +496,7 @@
207 swig
208 The path to the swig executable
209
210-swig-cpp
211+swig-cpp
212 Make SWIG create C++ files (default is C)
213
214 swig-opts
215@@ -506,7 +506,7 @@
216 The name of a section to get the Python executable from.
217 If not specified, then the buildout python option is used. The
218 Python executable is found in the executable option of the named
219- section.
220+ section.
221
222 To illustrate this, we'll use a directory containing the extdemo
223 example from the earlier section:
224@@ -532,7 +532,7 @@
225 ...
226 ... [demo]
227 ... recipe = zc.recipe.egg
228- ... eggs = demo
229+ ... eggs = demo
230 ... extdemo
231 ... entry-points = demo=demo:main
232 ... """ % dict(extdemo=extdemo))
233
234=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt'
235--- zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2009-08-28 20:55:09 +0000
236+++ zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2010-02-17 21:22:11 +0000
237@@ -24,8 +24,8 @@
238 <a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
239 </body></html>
240
241-We have a sample buildout. Let's update it's configuration file to
242-install the demo package using Python 2.4.
243+We have a sample buildout. Let's update its configuration file to
244+install the demo package using Python 2.4.
245
246 >>> write(sample_buildout, 'buildout.cfg',
247 ... """
248@@ -69,7 +69,7 @@
249 d setuptools-0.6-py2.4.egg
250 d setuptools-0.6-py2.5.egg
251 - zc.buildout-1.0-py2.5.egg
252-
253+
254 And the generated scripts invoke Python 2.4:
255
256 >>> import sys
257
258=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/tests.py'
259--- zc.recipe.egg_/src/zc/recipe/egg/tests.py 2009-06-22 14:10:12 +0000
260+++ zc.recipe.egg_/src/zc/recipe/egg/tests.py 2010-02-17 21:22:11 +0000
261@@ -36,7 +36,7 @@
262 def setUpSelecting(test):
263 zc.buildout.testselectingpython.setup(test)
264 zc.buildout.testing.install_develop('zc.recipe.egg', test)
265-
266+
267 def test_suite():
268 suite = unittest.TestSuite((
269 doctest.DocFileSuite(
270@@ -67,7 +67,7 @@
271 'setuptools-\S+\s+'
272 'zc.buildout-\S+\s*'
273 ),
274- '__buildout_signature__ = sample- zc.recipe.egg-'),
275+ '__buildout_signature__ = sample- zc.recipe.egg-\n'),
276 (re.compile('executable = [\S ]+python\S*', re.I),
277 'executable = python'),
278 (re.compile('find-links = http://localhost:\d+/'),
279@@ -89,7 +89,7 @@
280 (re.compile('extdemo[.]pyd'), 'extdemo.so')
281 ]),
282 ),
283-
284+
285 ))
286
287 if sys.version_info[:2] == (2, 5):
288@@ -115,7 +115,7 @@
289 ]),
290 ),
291 )
292-
293+
294 return suite
295
296 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to all changes: