Commit d22afa9d by Ed Page Committed by Ed Page

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
parent 4450993d
...@@ -34,19 +34,18 @@ def normalize_version(version): # type: (str) -> str ...@@ -34,19 +34,18 @@ def normalize_version(version): # type: (str) -> str
return str(Version(version)) return str(Version(version))
def _del_ro(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)
@contextmanager @contextmanager
def temporary_directory(*args, **kwargs): def temporary_directory(*args, **kwargs):
try: name = tempfile.mkdtemp(*args, **kwargs)
from tempfile import TemporaryDirectory
with TemporaryDirectory(*args, **kwargs) as name:
yield name
except ImportError:
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] def parse_requires(requires): # type: (str) -> List[str]
......
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