Commit c12d86b7 by Sébastien Eustace

Fix permission errors when adding/removing git dependencies on Windows

Co-authored-by: shawegit <shawegit@users.noreply.github.com>
Co-authored-by: Sébastien Eustace <sebastien@eustace.io>
parent fa728d06
# Change Log
## [Unreleased]
### Fixed
- Fixed permission errors when adding/removing git dependencies on Windows.
## [0.12.7] - 2018-11-08
### Fixed
......
......@@ -6,6 +6,7 @@ from subprocess import CalledProcessError
from poetry.config import Config
from poetry.utils.helpers import get_http_basic_auth
from poetry.utils.helpers import safe_rmtree
try:
......@@ -97,7 +98,7 @@ class PipInstaller(BaseInstaller):
if package.source_type == "git":
src_dir = self._env.path / "src" / package.name
if src_dir.exists():
shutil.rmtree(str(src_dir))
safe_rmtree(str(src_dir))
try:
self.run("uninstall", package.name, "-y")
......@@ -208,7 +209,7 @@ class PipInstaller(BaseInstaller):
src_dir = self._env.path / "src" / package.name
if src_dir.exists():
shutil.rmtree(str(src_dir))
safe_rmtree(str(src_dir))
src_dir.parent.mkdir(exist_ok=True)
......
......@@ -32,7 +32,7 @@ from poetry.repositories import Pool
from poetry.utils._compat import PY35
from poetry.utils._compat import Path
from poetry.utils.helpers import parse_requires
from poetry.utils.toml_file import TomlFile
from poetry.utils.helpers import safe_rmtree
from poetry.utils.env import Env
from poetry.utils.env import EnvCommandError
from poetry.utils.setup_reader import SetupReader
......@@ -196,7 +196,7 @@ class Provider:
except Exception:
raise
finally:
shutil.rmtree(tmp_dir.as_posix())
safe_rmtree(str(tmp_dir))
return [package]
......
import os
import re
import shutil
import stat
import tempfile
from contextlib import contextmanager
......@@ -89,3 +91,12 @@ def get_http_basic_auth(
return repo_auth["username"], repo_auth.get("password")
return None
def _on_rm_error(func, path, exc_info):
os.chmod(path, stat.S_IWRITE)
func(path)
def safe_rmtree(path):
shutil.rmtree(path, onerror=_on_rm_error)
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