Skip to content

Commit

Permalink
fix: Gracefully handle read-only sdists
Browse files Browse the repository at this point in the history
For a package without dependencies in pypi's database, like p4python,
the sdist is required.  The problem is p4python was developed in
perforce where all files are read-only by default and deleting the temp
directory fails.

So we need to use the custom-built temp directory and specially handle
read-only files to be able to use p4python in poetry.

Fixes #520
  • Loading branch information
epage authored and Ed Page committed Feb 29, 2020
1 parent ba48eb4 commit 997f71c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions poetry/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ def normalize_version(version): # type: (str) -> str
return str(Version(version))


def _del_ro(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)


@contextmanager
def temporary_directory(*args, **kwargs):
try:
from tempfile import TemporaryDirectory

with TemporaryDirectory(*args, **kwargs) as name:
yield name
except ImportError:
name = tempfile.mkdtemp(*args, **kwargs)
name = tempfile.mkdtemp(*args, **kwargs)

yield name
yield name

shutil.rmtree(name)
shutil.rmtree(name, onerror=_del_ro)


def parse_requires(requires): # type: (str) -> List[str]
Expand Down

0 comments on commit 997f71c

Please sign in to comment.