Skip to content

Commit

Permalink
utils/env: ensure user directories are created
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Oct 23, 2020
1 parent d660b51 commit 34662ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _add_scripts(self):
entry_points = self.convert_entry_points()

for scripts_path in self._env.script_dirs:
if is_dir_writable(scripts_path):
if is_dir_writable(path=scripts_path, create=True):
break
else:
self._io.error_line(
Expand Down
2 changes: 1 addition & 1 deletion poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def writable_candidates(self): # type: () -> List[Path]

self._writable_candidates = []
for candidate in self._candidates:
if not is_dir_writable(candidate):
if not is_dir_writable(path=candidate, create=True):
continue
self._writable_candidates.append(candidate)

Expand Down
4 changes: 3 additions & 1 deletion tests/utils/test_env_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from poetry.utils.env import SitePackages


def test_env_site_simple(tmp_dir):
def test_env_site_simple(tmp_dir, mocker):
# emulate permission error when creating directory
mocker.patch("poetry.utils._compat.Path.mkdir", side_effect=OSError())
site_packages = SitePackages(Path("/non-existent"), fallbacks=[Path(tmp_dir)])
candidates = site_packages.make_candidates(Path("hello.txt"), writable_only=True)
hello = Path(tmp_dir) / "hello.txt"
Expand Down

0 comments on commit 34662ba

Please sign in to comment.