Commit edde0942 authored by andreasjung's avatar andreasjung

- applied patch fixing rmtree issues on Windows (patch by

  Gottfried Ganssauge) (ajung)


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@84115 62d5b8a3-27da-0310-9561-8e5933582275
parent 41ac5395
......@@ -4,6 +4,12 @@ Status
Change History
**************
1.0.1 (unreleased)
==================
- applied patch fixing rmtree issues on Windows (patch by
Gottfried Ganssauge) (ajung)
1.0.0 (2008-01-13)
==================
......
......@@ -87,6 +87,13 @@ def system(command, input=''):
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 @@ def _runsetup(setup, executable, *args):
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 @@ def buildoutSetUp(test):
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 @@ def buildoutSetUp(test):
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'] = (
......
......@@ -2693,6 +2693,35 @@ def test_suite():
]),
),
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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment