Skip to content

Register .whl as a unpack format in shutil unpack #84027

Closed

Description

@chimeno
mannequin
BPO 39846
Nosy @chimeno, @pdxjohnny, @domdfcoding

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-03-04.10:24:15.384>
labels = ['type-feature', 'library', '3.11']
title = 'Register .whl as a unpack format in shutil unpack'
updated_at = <Date 2021-10-25.23:43:48.319>
user = 'https://github.com/chimeno'

bugs.python.org fields:

activity = <Date 2021-10-25.23:43:48.319>
actor = 'pdxjohnny'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-03-04.10:24:15.384>
creator = 'dchimeno'
dependencies = []
files = []
hgrepos = []
issue_num = 39846
keywords = []
message_count = 3.0
messages = ['363341', '396800', '405008']
nosy_count = 3.0
nosy_names = ['dchimeno', 'pdxjohnny', 'domdfcoding']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue39846'
versions = ['Python 3.11']

Linked PRs

Activity

  1. chimeno commented on Mar 4, 2020

    chimenomannequin
    MannequinAuthor

    While working on project with Python wheels I found myself adding:

    import shutil
    shutil.register_unpack_format('whl', ['.whl'], shutil._unpack_zipfile)
    ```
    
    Since PEP-427 explicitly says wheels are ZIP-format archive. https://www.python.org/dev/peps/pep-0427/
    
    I wonder if it's loable to register the unpack format by default so the 
    shutil.unpack_archive() function works without adding it.
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Mar 4, 2020
  3. domdfcoding commented on Jun 30, 2021

    domdfcodingmannequin
    Mannequin

    I have run into this myself and was surprised unpack_archive didn't support wheels. I would like to see support added, and don't mind doing the work myself.

    That said, I can see there being an issue with the number of supported zip-based formats ballooning: Java JARs, Android APKs etc.
    However, wheels have a use case for easily extracting them -- that's how they're installed. I can't see a use case for being able to *easily* extract other formats.

    If there's no opposition I will start work on a PR.

  4. added
    3.11only security fixes
    and removed on Jun 30, 2021
  5. pdxjohnny commented on Oct 25, 2021

    pdxjohnnymannequin
    Mannequin

    I ran into this today. Using a wrapper function around _make_zipfile due to

    cpython/Lib/shutil.py

    Lines 817 to 819 in d5650a1

    if format != 'zip':
    kwargs['owner'] = owner
    kwargs['group'] = group
    where there is a check for if the format is zip then don't pass owner and group.

    def make_whlfile(*args, owner=None, group=None, **kwargs):
        return shutil._make_zipfile(*args, **kwargs)
    
    
    shutil.register_archive_format("whl", make_whlfile, description="Wheel file")
    shutil.register_unpack_format(
        "whl", [".whl"], shutil._unpack_zipfile, description="Wheel file"
    )
    
  6. transferred this issue fromon Apr 10, 2022
  7. added a commit that references this issue on Oct 20, 2025
  8. added a commit that references this issue on Oct 30, 2026
  9. StanFromIreland commented on Oct 30, 2026

    @StanFromIreland
    Member

    This has now been added, and will be released in Python 3.16 thanks to @emmatyping! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions