Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Gracefully handle read-only sdists
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 Jun 2, 2020
commit d22afa9d933529c01b74a6127fa41ce49bf0182b
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