mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-03 11:50:19 +03:00
Fix git clone related issues on Windows
This commit is contained in:
parent
95bed8a4a0
commit
dc42ab48d2
|
@ -1050,8 +1050,15 @@ def make_tempdir() -> Generator[Path, None, None]:
|
||||||
"""
|
"""
|
||||||
d = Path(tempfile.mkdtemp())
|
d = Path(tempfile.mkdtemp())
|
||||||
yield d
|
yield d
|
||||||
|
|
||||||
|
# On Windows, git clones use read-only files, which cause permission errors
|
||||||
|
# when being deleted. This forcibly fixes permissions.
|
||||||
|
def force_remove(rmfunc, path, ex):
|
||||||
|
os.chmod(path, stat.S_IWRITE)
|
||||||
|
rmfunc(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(str(d))
|
shutil.rmtree(str(d), onerror=force_remove)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
warnings.warn(Warnings.W091.format(dir=d, msg=e))
|
warnings.warn(Warnings.W091.format(dir=d, msg=e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user