Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions doc/history.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release history
===============

Version 4.0.3
-------------

- Fix built wheels being created with overly restrictive ``0600`` permissions
instead of the normal, world-readable ``0644`` (:ghpull:`806`).

Version 4.0.2
-------------

Expand Down
6 changes: 6 additions & 0 deletions flit_core/flit_core/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def make_wheel_in(ini_path, wheel_directory, editable=False):
wb = WheelBuilder.from_ini_path(ini_path, fp)
wb.build(editable)

# mkstemp() creates the file with mode 0600, which is too strict
# for a build artifact - normalize it like the files inside the
# wheel are normalized.
st_mode = os.stat(temp_path).st_mode
os.chmod(temp_path, common.normalize_file_permissions(st_mode))

wheel_path = wheel_directory / wb.wheel_filename
os.replace(temp_path, str(wheel_path))
except:
Expand Down
16 changes: 16 additions & 0 deletions flit_core/tests_core/test_wheel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import stat
import sys
from pathlib import Path
from zipfile import ZipFile

import pytest
from testpath import assert_isfile

from flit_core.wheel import make_wheel_in, main
Expand Down Expand Up @@ -53,3 +57,15 @@ def test_license_files(tmp_path):
with ZipFile(info.file, 'r') as zf:
assert 'module1-0.1.dist-info/licenses/LICENSE' in zf.namelist()
assert 'module1-0.1.dist-info/licenses/module/vendor/LICENSE_VENDOR' in zf.namelist()


@pytest.mark.skipif(sys.platform == 'win32', reason='Windows does not have Unix file permissions')
def test_wheel_file_permissions(tmp_path):
# mkstemp(), which is used to create the wheel before it's renamed to
# its final name, creates files with mode 0600. The built wheel file
# itself should not be left that restrictive. Regression test for
# https://github.com/pypa/flit/issues/804
info = make_wheel_in(samples_dir / 'pep621' / 'pyproject.toml', tmp_path)
assert_isfile(info.file)
mode = stat.S_IMODE(os.stat(info.file).st_mode)
assert mode & 0o777 == 0o644, oct(mode)