Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
9a8cb0aa
Commit
9a8cb0aa
authored
Jun 08, 2018
by
kbu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #295: temporary egg files are created as read only and can't be deleted with shutil on Windows
parent
722dfc1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+8
-7
src/zc/buildout/rmtree.py
src/zc/buildout/rmtree.py
+17
-4
No files found.
src/zc/buildout/easy_install.py
View file @
9a8cb0aa
...
...
@@ -35,6 +35,7 @@ import subprocess
import
sys
import
tempfile
import
zc.buildout
import
zc.buildout.rmtree
import
warnings
try
:
...
...
@@ -453,7 +454,7 @@ class Installer:
return
result
finally
:
shutil
.
rmtree
(
tmp
)
zc
.
buildout
.
rmtree
.
rmtree
(
tmp
)
def
_obtain
(
self
,
requirement
,
source
=
None
):
# initialize out index for this project:
...
...
@@ -574,7 +575,7 @@ class Installer:
finally
:
if
tmp
!=
self
.
_download_cache
:
shutil
.
rmtree
(
tmp
)
zc
.
buildout
.
rmtree
.
rmtree
(
tmp
)
self
.
_env_rescan_dest
()
dist
=
self
.
_env
.
best_match
(
requirement
,
ws
)
...
...
@@ -804,11 +805,11 @@ class Installer:
return
[
dist
.
location
for
dist
in
dists
]
finally
:
shutil
.
rmtree
(
build_tmp
)
zc
.
buildout
.
rmtree
.
rmtree
(
build_tmp
)
finally
:
if
tmp
!=
self
.
_download_cache
:
shutil
.
rmtree
(
tmp
)
zc
.
buildout
.
rmtree
.
rmtree
(
tmp
)
def
_fix_file_links
(
self
,
links
):
for
link
in
links
:
...
...
@@ -945,7 +946,7 @@ def build(spec, dest, build_ext,
def
_rm
(
*
paths
):
for
path
in
paths
:
if
os
.
path
.
isdir
(
path
):
shutil
.
rmtree
(
path
)
zc
.
buildout
.
rmtree
.
rmtree
(
path
)
elif
os
.
path
.
exists
(
path
):
os
.
remove
(
path
)
...
...
@@ -1051,7 +1052,7 @@ def develop(setup, dest,
)).
encode
())
tmp3
=
tempfile
.
mkdtemp
(
'build'
,
dir
=
dest
)
undo
.
append
(
lambda
:
shutil
.
rmtree
(
tmp3
))
undo
.
append
(
lambda
:
zc
.
buildout
.
rmtree
.
rmtree
(
tmp3
))
args
=
[
executable
,
tsetup
,
'-q'
,
'develop'
,
'-mN'
,
'-d'
,
tmp3
]
...
...
@@ -1738,5 +1739,5 @@ def _move_to_eggs_dir_and_compile(dist, dest):
assert
newdist
is
not
None
# newloc above is missing our dist?!
finally
:
# Remember that temporary directories must be removed
shutil
.
rmtree
(
tmp_dest
)
zc
.
buildout
.
rmtree
.
rmtree
(
tmp_dest
)
return
newdist
src/zc/buildout/rmtree.py
View file @
9a8cb0aa
...
...
@@ -16,13 +16,15 @@
import
shutil
import
os
import
doctest
import
time
def
rmtree
(
path
):
"""
A variant of shutil.rmtree which tries hard to be successful
A variant of shutil.rmtree which tries hard to be successful
.
On windows shutil.rmtree aborts when it tries to delete a
read only file.
This tries to chmod the file to writeable and retries before giving up.
read only file or a file which is still handled by another
process (e.g. antivirus scanner). This tries to chmod the
file to writeable and retries 10 times before giving up.
>>> from tempfile import mkdtemp
...
...
@@ -55,7 +57,18 @@ def rmtree (path):
"""
def
retry_writeable
(
func
,
path
,
exc
):
os
.
chmod
(
path
,
384
)
# 0600
func
(
path
)
tries
=
10
while
tries
:
try
:
func
(
path
)
break
except
OSError
:
tries
-=
1
time
.
sleep
(
0.1
)
else
:
# tried 10 times without success, thus
# finally rethrow the last exception
raise
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment