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
=== modified file 'README.txt'
--- README.txt 2010-01-08 05:54:43 +0000
+++ README.txt 2010-02-17 21:22:11 +0000
@@ -126,7 +126,7 @@
126`--version` option of the bootstrap.py script::126`--version` option of the bootstrap.py script::
127127
128 $ python bootstrap.py --version 1.1.3128 $ python bootstrap.py --version 1.1.3
129 129
130The `zc.buildout project <http://svn.zope.org/zc.buildout/trunk>`_130The `zc.buildout project <http://svn.zope.org/zc.buildout/trunk>`_
131is a slightly more complex example of this type of buildout.131is a slightly more complex example of this type of buildout.
132132
133133
=== modified file 'src/zc/buildout/easy_install.py'
--- src/zc/buildout/easy_install.py 2009-11-11 21:21:11 +0000
+++ src/zc/buildout/easy_install.py 2010-02-17 21:22:11 +0000
@@ -495,7 +495,7 @@
495495
496 if dist is None:496 if dist is None:
497 raise zc.buildout.UserError(497 raise zc.buildout.UserError(
498 "Couln't download distribution %s." % avail)498 "Couldn't download distribution %s." % avail)
499499
500 if dist.precedence == pkg_resources.EGG_DIST:500 if dist.precedence == pkg_resources.EGG_DIST:
501 # It's already an egg, just fetch it into the dest501 # It's already an egg, just fetch it into the dest
@@ -628,9 +628,9 @@
628 logger.debug('Installing %s.', repr(specs)[1:-1])628 logger.debug('Installing %s.', repr(specs)[1:-1])
629629
630 path = self._path630 path = self._path
631 dest = self._dest631 destination = self._dest
632 if dest is not None and dest not in path:632 if destination is not None and destination not in path:
633 path.insert(0, dest)633 path.insert(0, destination)
634634
635 requirements = [self._constrain(pkg_resources.Requirement.parse(spec))635 requirements = [self._constrain(pkg_resources.Requirement.parse(spec))
636 for spec in specs]636 for spec in specs]
@@ -661,7 +661,7 @@
661 except pkg_resources.DistributionNotFound, err:661 except pkg_resources.DistributionNotFound, err:
662 [requirement] = err662 [requirement] = err
663 requirement = self._constrain(requirement)663 requirement = self._constrain(requirement)
664 if dest:664 if destination:
665 logger.debug('Getting required %r', str(requirement))665 logger.debug('Getting required %r', str(requirement))
666 else:666 else:
667 logger.debug('Adding required %r', str(requirement))667 logger.debug('Adding required %r', str(requirement))
668668
=== 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 @@
492 path = path[1:]492 path = path[1:]
493 return '/' + path.replace(os.path.sep, '/')493 return '/' + path.replace(os.path.sep, '/')
494494
495if sys.platform == 'win32':
496 sep = r'[\\/]' # Windows uses both sometimes.
497else:
498 sep = re.escape(os.path.sep)
495normalize_path = (499normalize_path = (
496 re.compile(500 re.compile(
497 r'''[^'" \t\n\r]+\%(sep)s_[Tt][Ee][Ss][Tt]_\%(sep)s([^"' \t\n\r]+)'''501 r'''[^'" \t\n\r]+%(sep)s_[Tt][Ee][Ss][Tt]_%(sep)s([^"' \t\n\r]+)'''
498 % dict(sep=os.path.sep)),502 % dict(sep=sep)),
499 _normalize_path,503 _normalize_path,
500 )504 )
501505
502506
=== modified file 'src/zc/buildout/tests.py'
--- src/zc/buildout/tests.py 2009-11-11 21:21:11 +0000
+++ src/zc/buildout/tests.py 2010-02-17 21:22:11 +0000
@@ -2880,7 +2880,7 @@
2880 'We have a develop egg: zc.buildout X.X.'),2880 'We have a develop egg: zc.buildout X.X.'),
2881 (re.compile(r'\\[\\]?'), '/'),2881 (re.compile(r'\\[\\]?'), '/'),
2882 (re.compile('WindowsError'), 'OSError'),2882 (re.compile('WindowsError'), 'OSError'),
2883 (re.compile(r'\[Error 17\] Cannot create a file '2883 (re.compile(r'\[Error \d+\] Cannot create a file '
2884 r'when that file already exists: '),2884 r'when that file already exists: '),
2885 '[Errno 17] File exists: '2885 '[Errno 17] File exists: '
2886 ),2886 ),
@@ -2933,6 +2933,7 @@
2933 (re.compile('extdemo[.]pyd'), 'extdemo.so'),2933 (re.compile('extdemo[.]pyd'), 'extdemo.so'),
2934 (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),2934 (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
2935 (re.compile(r'\\[\\]?'), '/'),2935 (re.compile(r'\\[\\]?'), '/'),
2936 (re.compile(r'\#!\S+\bpython\S*'), '#!/usr/bin/python'),
2936 ]+(sys.version_info < (2, 5) and [2937 ]+(sys.version_info < (2, 5) and [
2937 (re.compile('.*No module named runpy.*', re.S), ''),2938 (re.compile('.*No module named runpy.*', re.S), ''),
2938 (re.compile('.*usage: pdb.py scriptfile .*', re.S), ''),2939 (re.compile('.*usage: pdb.py scriptfile .*', re.S), ''),
29392940
=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/README.txt'
--- zc.recipe.egg_/src/zc/recipe/egg/README.txt 2009-11-06 22:33:23 +0000
+++ zc.recipe.egg_/src/zc/recipe/egg/README.txt 2010-02-17 21:22:11 +0000
@@ -46,7 +46,7 @@
46 <a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>46 <a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
47 </body></html>47 </body></html>
4848
49We have a sample buildout. Let's update it's configuration file to49We have a sample buildout. Let's update its configuration file to
50install the demo package.50install the demo package.
5151
52 >>> write(sample_buildout, 'buildout.cfg',52 >>> write(sample_buildout, 'buildout.cfg',
@@ -187,7 +187,7 @@
187 ... interpreter = py-demo187 ... interpreter = py-demo
188 ... """ % dict(server=link_server))188 ... """ % dict(server=link_server))
189189
190Note that we ommitted the entry point name from the recipe190Note that we omitted the entry point name from the recipe
191specification. We were able to do this because the scripts recipe is191specification. We were able to do this because the scripts recipe is
192the default entry point for the zc.recipe.egg egg.192the default entry point for the zc.recipe.egg egg.
193193
194194
=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/api.txt'
--- zc.recipe.egg_/src/zc/recipe/egg/api.txt 2008-07-15 23:09:58 +0000
+++ zc.recipe.egg_/src/zc/recipe/egg/api.txt 2010-02-17 21:22:11 +0000
@@ -15,7 +15,7 @@
15around the egg recipe:15around the egg recipe:
1616
17 >>> mkdir(sample_buildout, 'sample')17 >>> mkdir(sample_buildout, 'sample')
18 >>> write(sample_buildout, 'sample', 'sample.py', 18 >>> write(sample_buildout, 'sample', 'sample.py',
19 ... """19 ... """
20 ... import logging, os20 ... import logging, os
21 ... import zc.recipe.egg21 ... import zc.recipe.egg
@@ -53,7 +53,7 @@
53 >>> write(sample_buildout, 'sample', 'setup.py',53 >>> write(sample_buildout, 'sample', 'setup.py',
54 ... """54 ... """
55 ... from setuptools import setup55 ... from setuptools import setup
56 ... 56 ...
57 ... setup(57 ... setup(
58 ... name = "sample",58 ... name = "sample",
59 ... entry_points = {'zc.buildout': ['default = sample:Sample']},59 ... entry_points = {'zc.buildout': ['default = sample:Sample']},
@@ -95,12 +95,13 @@
95computed by the egg recipe by looking at .installed.cfg:95computed by the egg recipe by looking at .installed.cfg:
9696
97 >>> cat(sample_buildout, '.installed.cfg')97 >>> cat(sample_buildout, '.installed.cfg')
98 ... # doctest: +NORMALIZE_WHITESPACE
98 [buildout]99 [buildout]
99 installed_develop_eggs = /sample-buildout/develop-eggs/sample.egg-link100 installed_develop_eggs = /sample-buildout/develop-eggs/sample.egg-link
100 parts = sample-part101 parts = sample-part
101 <BLANKLINE>102 <BLANKLINE>
102 [sample-part]103 [sample-part]
103 __buildout_installed__ = 104 __buildout_installed__ =
104 __buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==105 __buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
105 zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==106 zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==
106 setuptools-0.6-py2.4.egg107 setuptools-0.6-py2.4.egg
107108
=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/custom.txt'
--- zc.recipe.egg_/src/zc/recipe/egg/custom.txt 2008-08-27 06:48:40 +0000
+++ zc.recipe.egg_/src/zc/recipe/egg/custom.txt 2010-02-17 21:22:11 +0000
@@ -50,7 +50,7 @@
50swig50swig
51 The path to the swig executable51 The path to the swig executable
5252
53swig-cpp 53swig-cpp
54 Make SWIG create C++ files (default is C)54 Make SWIG create C++ files (default is C)
5555
56swig-opts56swig-opts
@@ -73,14 +73,14 @@
73 alternate index with this option. If you use the links option and73 alternate index with this option. If you use the links option and
74 if the links point to the needed distributions, then the index can74 if the links point to the needed distributions, then the index can
75 be anything and will be largely ignored. In the examples, here,75 be anything and will be largely ignored. In the examples, here,
76 we'll just point to an empty directory on our link server. This 76 we'll just point to an empty directory on our link server. This
77 will make our examples run a little bit faster.77 will make our examples run a little bit faster.
7878
79python79python
80 The name of a section to get the Python executable from.80 The name of a section to get the Python executable from.
81 If not specified, then the buildout python option is used. The81 If not specified, then the buildout python option is used. The
82 Python executable is found in the executable option of the named82 Python executable is found in the executable option of the named
83 section. 83 section.
8484
85environment85environment
86 The name of a section with additional environment variables. The86 The name of a section with additional environment variables. The
@@ -188,7 +188,7 @@
188 ...188 ...
189 ... [demo]189 ... [demo]
190 ... recipe = zc.recipe.egg190 ... recipe = zc.recipe.egg
191 ... eggs = demo 191 ... eggs = demo
192 ... extdemo192 ... extdemo
193 ... entry-points = demo=demo:main193 ... entry-points = demo=demo:main
194 ... """ % dict(server=link_server))194 ... """ % dict(server=link_server))
@@ -270,7 +270,7 @@
270 ...270 ...
271 ... [demo]271 ... [demo]
272 ... recipe = zc.recipe.egg272 ... recipe = zc.recipe.egg
273 ... eggs = demo 273 ... eggs = demo
274 ... extdemo ==1.4274 ... extdemo ==1.4
275 ... entry-points = demo=demo:main275 ... entry-points = demo=demo:main
276 ... """ % dict(server=link_server))276 ... """ % dict(server=link_server))
@@ -440,7 +440,7 @@
440 Uninstalling extdemo.440 Uninstalling extdemo.
441 Installing extdemo.441 Installing extdemo.
442 zip_safe flag not set; analyzing archive contents...442 zip_safe flag not set; analyzing archive contents...
443 443
444 >>> rmdir(sample_buildout, 'recipes')444 >>> rmdir(sample_buildout, 'recipes')
445445
446446
@@ -496,7 +496,7 @@
496swig496swig
497 The path to the swig executable497 The path to the swig executable
498498
499swig-cpp 499swig-cpp
500 Make SWIG create C++ files (default is C)500 Make SWIG create C++ files (default is C)
501501
502swig-opts502swig-opts
@@ -506,7 +506,7 @@
506 The name of a section to get the Python executable from.506 The name of a section to get the Python executable from.
507 If not specified, then the buildout python option is used. The507 If not specified, then the buildout python option is used. The
508 Python executable is found in the executable option of the named508 Python executable is found in the executable option of the named
509 section. 509 section.
510510
511To illustrate this, we'll use a directory containing the extdemo511To illustrate this, we'll use a directory containing the extdemo
512example from the earlier section:512example from the earlier section:
@@ -532,7 +532,7 @@
532 ...532 ...
533 ... [demo]533 ... [demo]
534 ... recipe = zc.recipe.egg534 ... recipe = zc.recipe.egg
535 ... eggs = demo 535 ... eggs = demo
536 ... extdemo536 ... extdemo
537 ... entry-points = demo=demo:main537 ... entry-points = demo=demo:main
538 ... """ % dict(extdemo=extdemo))538 ... """ % dict(extdemo=extdemo))
539539
=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt'
--- zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2009-08-28 20:55:09 +0000
+++ zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2010-02-17 21:22:11 +0000
@@ -24,8 +24,8 @@
24 <a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>24 <a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
25 </body></html>25 </body></html>
2626
27We have a sample buildout. Let's update it's configuration file to27We have a sample buildout. Let's update its configuration file to
28install the demo package using Python 2.4. 28install the demo package using Python 2.4.
2929
30 >>> write(sample_buildout, 'buildout.cfg',30 >>> write(sample_buildout, 'buildout.cfg',
31 ... """31 ... """
@@ -69,7 +69,7 @@
69 d setuptools-0.6-py2.4.egg69 d setuptools-0.6-py2.4.egg
70 d setuptools-0.6-py2.5.egg70 d setuptools-0.6-py2.5.egg
71 - zc.buildout-1.0-py2.5.egg71 - zc.buildout-1.0-py2.5.egg
72 72
73And the generated scripts invoke Python 2.4:73And the generated scripts invoke Python 2.4:
7474
75 >>> import sys75 >>> import sys
7676
=== modified file 'zc.recipe.egg_/src/zc/recipe/egg/tests.py'
--- zc.recipe.egg_/src/zc/recipe/egg/tests.py 2009-06-22 14:10:12 +0000
+++ zc.recipe.egg_/src/zc/recipe/egg/tests.py 2010-02-17 21:22:11 +0000
@@ -36,7 +36,7 @@
36def setUpSelecting(test):36def setUpSelecting(test):
37 zc.buildout.testselectingpython.setup(test)37 zc.buildout.testselectingpython.setup(test)
38 zc.buildout.testing.install_develop('zc.recipe.egg', test)38 zc.buildout.testing.install_develop('zc.recipe.egg', test)
39 39
40def test_suite():40def test_suite():
41 suite = unittest.TestSuite((41 suite = unittest.TestSuite((
42 doctest.DocFileSuite(42 doctest.DocFileSuite(
@@ -67,7 +67,7 @@
67 'setuptools-\S+\s+'67 'setuptools-\S+\s+'
68 'zc.buildout-\S+\s*'68 'zc.buildout-\S+\s*'
69 ),69 ),
70 '__buildout_signature__ = sample- zc.recipe.egg-'),70 '__buildout_signature__ = sample- zc.recipe.egg-\n'),
71 (re.compile('executable = [\S ]+python\S*', re.I),71 (re.compile('executable = [\S ]+python\S*', re.I),
72 'executable = python'),72 'executable = python'),
73 (re.compile('find-links = http://localhost:\d+/'),73 (re.compile('find-links = http://localhost:\d+/'),
@@ -89,7 +89,7 @@
89 (re.compile('extdemo[.]pyd'), 'extdemo.so')89 (re.compile('extdemo[.]pyd'), 'extdemo.so')
90 ]),90 ]),
91 ),91 ),
92 92
93 ))93 ))
9494
95 if sys.version_info[:2] == (2, 5):95 if sys.version_info[:2] == (2, 5):
@@ -115,7 +115,7 @@
115 ]),115 ]),
116 ),116 ),
117 )117 )
118 118
119 return suite119 return suite
120120
121if __name__ == '__main__':121if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to all changes: