Commit a29a456d by boyeah Committed by Sébastien Eustace

Normalize permissions of whl file created during build. (#1020)

`poetry build` creates a whl file using `os.mkstemp`. The file is
created with very restrictive permissions. This commit ensures these are
normalized before the build starts.

Partly addresses https://github.com/sdispater/poetry/issues/671.
parent 571e5634
...@@ -65,6 +65,10 @@ class WheelBuilder(Builder): ...@@ -65,6 +65,10 @@ class WheelBuilder(Builder):
(fd, temp_path) = tempfile.mkstemp(suffix=".whl") (fd, temp_path) = tempfile.mkstemp(suffix=".whl")
st_mode = os.stat(temp_path).st_mode
new_mode = normalize_file_permissions(st_mode)
os.chmod(temp_path, new_mode)
with zipfile.ZipFile( with zipfile.ZipFile(
os.fdopen(fd, "w+b"), mode="w", compression=zipfile.ZIP_DEFLATED os.fdopen(fd, "w+b"), mode="w", compression=zipfile.ZIP_DEFLATED
) as zip_file: ) as zip_file:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import os
import pytest import pytest
import re import re
import shutil import shutil
...@@ -159,6 +160,8 @@ def test_complete(): ...@@ -159,6 +160,8 @@ def test_complete():
whl = module_path / "dist" / "my_package-1.2.3-py3-none-any.whl" whl = module_path / "dist" / "my_package-1.2.3-py3-none-any.whl"
assert whl.exists() assert whl.exists()
if sys.platform != "win32":
assert (os.stat(str(whl)).st_mode & 0o777) == 0o644
zip = zipfile.ZipFile(str(whl)) zip = zipfile.ZipFile(str(whl))
......
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