mirror of https://github.com/astral-sh/uv
Fix incorrect file permissions in wheel packages (#14930)
Fixes #14920 ## Summary Problem: When building wheel packages, metadata files (such as RECORD, METADATA, WHEEL, and license files) were being created with incorrect Unix permissions (--w--wx---), lacking read permissions and having unexpected executable permissions. Solution: The fix ensures that all metadata files in wheel packages are created with proper 644 (rw-r--r--) permissions by: - Adding explicit unix_permissions(0o644) setting in the write_bytes method for metadata files - Updating permission constants to use octal notation for clarity - Improving code comments to document the permission settings Impact: This change ensures wheel packages created by uv have standard file permissions consistent with other Python build tools like setuptools, improving compatibility and following Python packaging best practices.
This commit is contained in:
parent
c97d12bcf3
commit
55df845922
|
|
@ -622,7 +622,7 @@ mod tests {
|
|||
// Check that the wheel is reproducible across platforms.
|
||||
assert_snapshot!(
|
||||
format!("{:x}", sha2::Sha256::digest(fs_err::read(&wheel_path).unwrap())),
|
||||
@"ac3f68ac448023bca26de689d80401bff57f764396ae802bf4666234740ffbe3"
|
||||
@"342bf60c8406144f459358cde92408686c1631fe22389d042ce80379e589d6ec"
|
||||
);
|
||||
assert_snapshot!(build.wheel_contents.join("\n"), @r"
|
||||
built_by_uv-0.1.0.data/data/
|
||||
|
|
|
|||
|
|
@ -621,8 +621,8 @@ impl ZipDirectoryWriter {
|
|||
path: &str,
|
||||
executable_bit: bool,
|
||||
) -> Result<Box<dyn Write + 'slf>, Error> {
|
||||
// 644 is the default of the zip crate.
|
||||
let permissions = if executable_bit { 775 } else { 664 };
|
||||
// Set file permissions: 644 (rw-r--r--) for regular files, 755 (rwxr-xr-x) for executables
|
||||
let permissions = if executable_bit { 0o755 } else { 0o644 };
|
||||
let options = zip::write::SimpleFileOptions::default()
|
||||
.unix_permissions(permissions)
|
||||
.compression_method(self.compression);
|
||||
|
|
@ -634,7 +634,10 @@ impl ZipDirectoryWriter {
|
|||
impl DirectoryWriter for ZipDirectoryWriter {
|
||||
fn write_bytes(&mut self, path: &str, bytes: &[u8]) -> Result<(), Error> {
|
||||
trace!("Adding {}", path);
|
||||
let options = zip::write::SimpleFileOptions::default().compression_method(self.compression);
|
||||
// Set appropriate permissions for metadata files (644 = rw-r--r--)
|
||||
let options = zip::write::SimpleFileOptions::default()
|
||||
.unix_permissions(0o644)
|
||||
.compression_method(self.compression);
|
||||
self.writer.start_file(path, options)?;
|
||||
self.writer.write_all(bytes)?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue