Skip to content

PEP 441 - Improving Python Zip Application Support #67679

Closed

Description

@pfmoore
BPO 23491
Nosy @brettcannon, @pfmoore, @dholth, @ethanfurman, @berkerpeksag, @JimJJewett, @serhiy-storchaka, @zooba
Files
  • pep441.patch
  • pep441.patch
  • pep-441.patch
  • pep-441.v4.patch
  • pep-441.v5.patch
  • pep-441.v6.patch
  • 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 = 'https://github.com/zooba'
    closed_at = <Date 2015-03-13.14:45:26.083>
    created_at = <Date 2015-02-20.12:52:51.249>
    labels = ['type-feature', 'library']
    title = 'PEP 441 - Improving Python Zip Application Support'
    updated_at = <Date 2015-03-13.15:06:38.893>
    user = 'https://github.com/pfmoore'

    bugs.python.org fields:

    activity = <Date 2015-03-13.15:06:38.893>
    actor = 'paul.moore'
    assignee = 'steve.dower'
    closed = True
    closed_date = <Date 2015-03-13.14:45:26.083>
    closer = 'brett.cannon'
    components = ['Library (Lib)']
    creation = <Date 2015-02-20.12:52:51.249>
    creator = 'paul.moore'
    dependencies = []
    files = ['38187', '38192', '38250', '38258', '38389', '38419']
    hgrepos = []
    issue_num = 23491
    keywords = ['patch']
    message_count = 42.0
    messages = ['236276', '236285', '236286', '236291', '236301', '236308', '236455', '236457', '236458', '236459', '236531', '236534', '236669', '236670', '236672', '236673', '236675', '236676', '236678', '236680', '236682', '236688', '236689', '236694', '236698', '236700', '236704', '236705', '236707', '236736', '236740', '236745', '237304', '237539', '237544', '237740', '237741', '237764', '237766', '238028', '238029', '238032']
    nosy_count = 9.0
    nosy_names = ['brett.cannon', 'paul.moore', 'dholth', 'ethan.furman', 'python-dev', 'berker.peksag', 'Jim.Jewett', 'serhiy.storchaka', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23491'
    versions = ['Python 3.5']

    Activity

    1. pfmoore commented on Feb 20, 2015

      @pfmoore
      MemberAuthor

      This is the patch for PEP-441 (Zip Application Support).

      Steve, could you check the installer changes, please? I haven't managed to get a setup where I can test the installer, and I'm not aware of any WiX coding tools, so I just edited the XML files by hand with grep and vim, and checked that Tools/buildmsi.bat doesn't error in anything I wrote... (There's a CRC check error in TCL, but that was there before I made changes)

      light.exe : error LGHT0216: An unexpected Win32 exception with error code 0x17 occurred while accessing file 'C:\Work\Projects\cpython\externals\tcltk64\lib\tcl8.6\tzdata\America\Detroit': Data error (cyclic redundancy check) [C:\Work\Projects\cpython\Tools\msi\tcltk\tcltk.wixproj]

      Also, I don't *think* I need to do anything for the new files in Doc\Lib, Lib and Lib\test to get picked up, but I'm not sure how to check that.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Feb 20, 2015
    3. zooba commented on Feb 20, 2015

      @zooba
      Member

      The installer changes look fine, though there shouldn't be PATH related strings in exe/, so there's probably a separate issue there. Wix doesn't really have any editors that aren't just XML editors.

      We probably want to update the ContentType value from text/plain for all the shortcuts, though I'm not sure what to (it affects the implicit associations and extra commands on the files, inc. Open With).

      The easiest way to make sure the files are in the installer is to install it :) But if they're just .py files under Lib/ then they'll be there.

    4. zooba commented on Feb 20, 2015

      @zooba
      Member

      I haven't looked closely at the rest, btw. Will try and find time today or tomorrow.

    5. pfmoore commented on Feb 20, 2015

      @pfmoore
      MemberAuthor

      Thanks for checking, Steve. I don't get an installer because of the checksum error quoted, although I did get the component msi files.

      As far as content type is concerned, I wasn't sure what effect it had so I just copied what was there. I guess application/zip might be better for .pyz files, based on what you said?

      I'm not sure what you meant by the comment about exe/. All I did was mention .pyz as well as .py - although I don't see where the PathDescription string us used so I may be missing something important!

    6. zooba commented on Feb 20, 2015

      @zooba
      Member

      Either "application/zip" or "application/x-zip-compressed", I'm not sure exactly what the difference is, but the default .zip association has the latter.

      The CRC error may be your machine or it may be because we're currently running on unstable WiX releases (hey, everything else is unstable right now :) ). If you can edit and re-save that file, I'd expect it to work, otherwise the 32-bit installer should be okay.

      The exe/ comment is more a note for myself, sorry. Those strings are unused and should be removed (I'll do that now - got a few things to fix).

    7. pfmoore commented on Feb 20, 2015

      @pfmoore
      MemberAuthor

      Thanks. Updated patch with the new mime-type.

      Looks like there's disk errors on that file with the CRC check. Lovely :-)

    8. dholth commented on Feb 23, 2015

      dholthmannequin
      Mannequin

      It looks like your patch does not register PYZW in Windows

    9. zooba commented on Feb 23, 2015

      @zooba
      Member

      It registers the association, but doesn't add it to PATHEXT.

    10. dholth commented on Feb 23, 2015

      dholthmannequin
      Mannequin

      I don't see the string PYZW anywhere in the patch, I only see PYZ,
      perhaps I don't know enough about this bug tracker or registering file
      extensions?

      On Mon, Feb 23, 2015, at 01:19 PM, Steve Dower wrote:

      Steve Dower added the comment:

      It registers the association, but doesn't add it to PATHEXT.

      ----------


      Python tracker <report@bugs.python.org>
      <http://bugs.python.org/issue23491\>


    11. zooba commented on Feb 23, 2015

      @zooba
      Member

      It's this line:

      <Extension Id="$(var.ArchiveFileExtension)w" ContentType="application/x-zip-compressed">
      

      $(var.ArchiveFileExtension) expands to "pyz" or "pxz" depending on the build options, and the literal w makes it pyzw or pxzw.

    12. dholth commented on Feb 24, 2015

      dholthmannequin
      Mannequin

      Spelling

      raise PackError("Cannot spacify entry point if the source has __main__.py")

    13. pfmoore commented on Feb 24, 2015

      @pfmoore
      MemberAuthor

      Thanks, I'll fix for the next iteration of the patch.

    14. 17 remaining items

    15. pfmoore commented on Feb 27, 2015

      @pfmoore
      MemberAuthor

      Updated patch including (I hope!) all review comments so far.

    16. serhiy-storchaka commented on Feb 27, 2015

      @serhiy-storchaka
      Member

      There is not well known old way how to make executable Python files on Windows. Add line "@python -x %0 %*" at the start of your Python script and rename the script to *.bat. The "-x" option makes Python to skip first line that is not Python, and @ forbids echoing executed command in bat-file.

      Could zipapp support this feature?

    17. pfmoore commented on Feb 27, 2015

      @pfmoore
      MemberAuthor

      I'm -1 on this. The whole point of having a .pyz extension is so that you don't need to use an extension that's for files containing text to hold binary data.

      If you want to do this, use zipapp and specify no interpreter line, then add the @python line yourself. Or just use a zip utility. Or build your own command line app. With the ability to supply an open file to create_archive, it's a 3-liner:

      with open(dest_filename, 'wb') as f:
          f.write(b'@python -x %0 %*\n')
          zipapp.create_archive(source_dir, f)
    18. pfmoore commented on Mar 5, 2015

      @pfmoore
      MemberAuthor

      There have been no further comments for a while now. Could this be committed by someone?

    19. berkerpeksag commented on Mar 8, 2015

      @berkerpeksag
      Member

      I left a couple of minor comments on Rietveld.

    20. pfmoore commented on Mar 8, 2015

      @pfmoore
      MemberAuthor

      New patch incorporating Berker's comments

    21. pfmoore commented on Mar 10, 2015

      @pfmoore
      MemberAuthor

      There's a problem with the latest patch, it's lost the MSI updates somehow. I'll add them back in this evening, please don't commit before a v6 patch is available,

    22. pfmoore commented on Mar 10, 2015

      @pfmoore
      MemberAuthor

      Steve Dower - could you please review the updated patch here. The WiX changes specifically are intended to register the .pyz extension with the launcher, but I can see no code that does this for a per-user install. I've copied the same code for the .py extension so I don't think I've missed anything, but I can't see how this would work in practice.

    23. zooba commented on Mar 10, 2015

      @zooba
      Member

      The whole installer is run with a different global flag depending on the type of install. So it's automatic, though sometimes you can't do both per-user and all-user changes at the same time (not that you should anyway).

    24. pfmoore commented on Mar 10, 2015

      @pfmoore
      MemberAuthor

      OK, so if the installer changes look good to you, then this PR is once again ready to go. Sorry to anyone watching for the glitch.

    25. python-dev commented on Mar 13, 2015

      python-devmannequin
      Mannequin

      New changeset d1e9f337fea1 by Brett Cannon in branch 'default':
      Issue bpo-23491: Implement PEP-441: Improving Python Zip Application Support
      https://hg.python.org/cpython/rev/d1e9f337fea1

    26. brettcannon commented on Mar 13, 2015

      @brettcannon
      Member

      Thanks for the patch, Paul! I touched up the formatting to be more PEP-8 compliant and fixed the tests as they initially failed for me (TESTFN didn't exist prior to you trying to make a directory, so it just failed; switched to tempfile.TemporaryDirectory instead).

    27. pfmoore commented on Mar 13, 2015

      @pfmoore
      MemberAuthor

      Thanks Brett! Apologies about the TESTFN issue - I changed it (from TemporaryDirectory, in fact) based on one of the review comments - it looks like I didn't test the change properly. My mistake, thanks for catching it.

    28. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    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