[Checkins] SVN: zc.buildout/trunk/ - applied patch fixing rmtree
issues on Windows (patch by
Andreas Jung
andreas at andreas-jung.com
Thu Feb 21 10:17:55 EST 2008
Log message for revision 84115:
- applied patch fixing rmtree issues on Windows (patch by
Gottfried Ganssauge) (ajung)
Changed:
U zc.buildout/trunk/CHANGES.txt
U zc.buildout/trunk/src/zc/buildout/testing.py
U zc.buildout/trunk/src/zc/buildout/tests.py
A zc.buildout/trunk/src/zc/buildout/windows.txt
-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt 2008-02-21 15:01:12 UTC (rev 84114)
+++ zc.buildout/trunk/CHANGES.txt 2008-02-21 15:17:55 UTC (rev 84115)
@@ -4,6 +4,12 @@
Change History
**************
+1.0.1 (unreleased)
+==================
+
+- applied patch fixing rmtree issues on Windows (patch by
+ Gottfried Ganssauge) (ajung)
+
1.0.0 (2008-01-13)
==================
Modified: zc.buildout/trunk/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/testing.py 2008-02-21 15:01:12 UTC (rev 84114)
+++ zc.buildout/trunk/src/zc/buildout/testing.py 2008-02-21 15:17:55 UTC (rev 84115)
@@ -87,6 +87,13 @@
def get(url):
return urllib2.urlopen(url).read()
+def _rmtree (path):
+ def retry_writeable (func, path, exc):
+ os.chmod (path, 0600)
+ func (path)
+
+ shutil.rmtree (path, onerror = retry_writeable)
+
def _runsetup(setup, executable, *args):
if os.path.isdir(setup):
setup = os.path.join(setup, 'setup.py')
@@ -102,7 +109,7 @@
os.chdir(d)
os.spawnle(os.P_WAIT, executable, executable, setup, *args)
if os.path.exists('build'):
- shutil.rmtree('build')
+ _rmtree('build')
finally:
os.chdir(here)
@@ -163,7 +170,7 @@
base = tempfile.mkdtemp('buildoutSetUp')
- register_teardown(lambda base=base: shutil.rmtree(base))
+ register_teardown(lambda base=base: _rmtree(base))
old_home = os.environ.get('HOME')
os.environ['HOME'] = os.path.join(base, 'bbbBadHome')
@@ -178,7 +185,7 @@
os.mkdir(base)
tmp = tempfile.mkdtemp('buildouttests')
- register_teardown(lambda: shutil.rmtree(tmp))
+ register_teardown(lambda: _rmtree(tmp))
zc.buildout.easy_install.default_index_url = 'file://'+tmp
os.environ['buildout-testing-index-url'] = (
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2008-02-21 15:01:12 UTC (rev 84114)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2008-02-21 15:17:55 UTC (rev 84115)
@@ -2693,6 +2693,35 @@
]),
),
zc.buildout.testselectingpython.test_suite(),
+ doctest.DocFileSuite(
+ 'windows.txt',
+ setUp=zc.buildout.testing.buildoutSetUp,
+ tearDown=zc.buildout.testing.buildoutTearDown,
+ checker=renormalizing.RENormalizing([
+ zc.buildout.testing.normalize_path,
+ zc.buildout.testing.normalize_script,
+ zc.buildout.testing.normalize_egg_py,
+ (re.compile('__buildout_signature__ = recipes-\S+'),
+ '__buildout_signature__ = recipes-SSSSSSSSSSS'),
+ (re.compile('executable = \S+python\S*'),
+ 'executable = python'),
+ (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
+ (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
+ 'zc.buildout.egg'),
+ (re.compile('creating \S*setup.cfg'), 'creating setup.cfg'),
+ (re.compile('hello\%ssetup' % os.path.sep), 'hello/setup'),
+ (re.compile('Picked: (\S+) = \S+'),
+ 'Picked: \\1 = V.V'),
+ (re.compile(r'We have a develop egg: zc.buildout (\S+)'),
+ 'We have a develop egg: zc.buildout X.X.'),
+ (re.compile(r'\\[\\]?'), '/'),
+ (re.compile('WindowsError'), 'OSError'),
+ (re.compile(r'\[Error 17\] Cannot create a file '
+ r'when that file already exists: '),
+ '[Errno 17] File exists: '
+ ),
+ ])
+ ),
))
return suite
Added: zc.buildout/trunk/src/zc/buildout/windows.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/windows.txt (rev 0)
+++ zc.buildout/trunk/src/zc/buildout/windows.txt 2008-02-21 15:17:55 UTC (rev 84115)
@@ -0,0 +1,66 @@
+zc.buildout on MS-Windows
+=========================
+
+Certain aspects of every software project are dependent on the
+operating system used.
+The same - of course - applies to zc.buildout.
+
+To test that windows doesn't get in the way, we'll test some system
+dependent aspects.
+The following recipe will create a read-only file which shutil.rmtree
+can't delete.
+
+ >>> mkdir('recipe')
+ >>> write('recipe', 'recipe.py',
+ ... '''
+ ... import os
+ ... class Recipe:
+ ... def __init__(self, buildout, name, options):
+ ... self.location = os.path.join(
+ ... buildout['buildout']['parts-directory'],
+ ... name)
+ ...
+ ... def install(self):
+ ... print "can't remove read only files"
+ ... if not os.path.exists (self.location):
+ ... os.makedirs (self.location)
+ ...
+ ... name = os.path.join (self.location, 'readonly.txt')
+ ... open (name, 'w').write ('this is a read only file')
+ ... os.chmod (name, 0400)
+ ... return ()
+ ...
+ ... update = install
+ ... ''')
+
+ >>> write('recipe', 'setup.py',
+ ... '''
+ ... from setuptools import setup
+ ... setup(name='spam', version='1', py_modules=['recipe'],
+ ... entry_points={'zc.buildout': ['default = recipe:Recipe']},
+ ... )
+ ... ''')
+
+ >>> write('recipe', 'README', '')
+
+ >>> print system(buildout+' setup recipe bdist_egg'), # doctest: +ELLIPSIS
+ Running setup script 'recipe/setup.py'.
+ ...
+
+and we'll configure a buildout to use it:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... parts = foo
+ ... find-links = %s
+ ...
+ ... [foo]
+ ... recipe = spam
+ ... ''' % join('recipe', 'dist'))
+
+ >>> print system(buildout),
+ Getting distribution for 'spam'.
+ Got spam 1.
+ Installing foo.
+ can't remove read only files
More information about the Checkins
mailing list