Movatterモバイル変換
[0]ホーム
[Python-Dev] PEP 441 - Improving Python ZIP Application Support
Paul Moorep.f.moore at gmail.com
Sat Feb 14 15:44:14 CET 2015
I'm looking at putting together a patch for CPython to implement PEP441. In doing so, there are a few issues that I'd like to raise withthe PEP. These are all to do with the supporting app "pyzaa" (IIRC,Nick proposed renaming this to "pyzapp", which I like, but it's not abig deal either way).1. The PEP says that the application will warn if you try to add Cextensions to the archive. In practice, this will be quite hard to do- extensions vary across platforms, and it's not only C extensionsthat won't work from an archive (consider a DLL with a pure-pythonctypes wrapper). We could check the filenames for "known" extensions(maybe using importlib.machinery.EXTENSION_SUFFIXES, but that variesby platform) but I think that's going to be fragile. IMO, the costsaren't worth the benefits, and I'd like to remove this proposal andsimply document that applications packed up with pyzaa need to betested to ensure they work from a zipfile.2. The option to compile Python source seems to me to be of limiteduse. It ties the archive to a particular Python version (moreprecisely, only one version gets the benefits of precompiledbytecode). It's also tricky to implement, particularly the option tocompile an existing archive, because there standard library py_compileand compileall modules work on the filesystem, and for compiling filesin an archive it would be better to build the bytecode in memory (noneed to use tempfiles). I'd prefer to say that if users want toinclude bytecode, they can precompile on disk (using compileall) foras many versions as they want.FWIW, Daniel's standalone pyzaa program doesn't currently includeeither of the above features.As well as removing things, I'd like to add a programmable API for theutility. At the moment I only have a rough idea of how that wouldwork, but I'm thinking of a PyZApp class, which can be created from afilename or an open stream (like a ZipFile object) and which hasmethods to set the shebang line, setting the main entry point, andadding files or directories. Does that need to go into the PEP or isit OK to review the API as part of the patch? I don't mind either way,but my normal coding process tends to be to fiddle with the API as Icode it up and use it in the main app, so I'd normally leavedocumenting the final API till it's written...If the above seems like a reasonable plan, I'll work up a patch withthe intention that it gets approved and implemented in time for 3.5.Paul
More information about the Python-Devmailing list
[8]ページ先頭