Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
On 7/11/07, Andy C <[EMAIL PROTECTED]> wrote: > The good thing about this is that it's extremely simple -- basically > 20 lines of C code to add a -z flag that calls a 3-line Python > function in the runpy module. Instead of requiring a -z flag, why not have the interpreter peak at the file to see if it starts with one of the ZIP magic numbers? That way it Just Works. -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Add a -z interpreter flag to execute a zip file
I'd like to request comments on this patch I submitted: https://sourceforge.net/tracker/index.php?func=detail&aid=1739468&group_id=5470&atid=305470 There are many details given in the comments on that page. This can be used to deploy Python programs in a very lightweight and cross-platform way. You could imagine a cgi script or a light web app server being deployed like this. I have personally deployed Python programs using zip files and this would get rid of the need for boilerplate needed for each platform. The good thing about this is that it's extremely simple -- basically 20 lines of C code to add a -z flag that calls a 3-line Python function in the runpy module. I don't believe it overlaps with anything that already exists. py2exe and py2app are platform specific and bundle the Python interpreter. This will be a cross platform binary that doesn't bundle the Python interpreter. It doesn't require eggs but I think it would work fine with eggs, and could help fix a little bug as I mentioned on the patch page. Nick Coghlan has reviewed the patch and seems to think it's a good idea. Thomas Wouters also said he likes it, and I ran it by Guido earlier and he seemed to think the idea is good, although I don't think he has seen the implementation. thanks, Andy ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Planned updates for cjkcodecs before 2.4a1
Hello, I am e-mailing you because I am looking for a way to use the CJK codecs and the CJK module that I found for Python. I wasn't able to find any documentation on how to use it so I would appreciate it if you would let me know where I could find it. Thank you in advance. Taehee Kim -- [EMAIL PROTECTED] ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Planned updates for cjkcodecs before 2.4a1
On Fri, Jul 13, 2007, Tae-Hee Kim wrote: > > I am e-mailing you because I am looking for a way to use the CJK > codecs and the CJK module that I found for Python. > > I wasn't able to find any documentation on how to use it so I would > appreciate it if you would let me know where I could find it. You're asking in the wrong place, please use comp.lang.python; python-dev is for discussion of bug reports and similar topics. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ This is Python. We don't care much about theory, except where it intersects with useful practice. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
On 7/12/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > On 7/11/07, Andy C <[EMAIL PROTECTED]> wrote: > > The good thing about this is that it's extremely simple -- basically > > 20 lines of C code to add a -z flag that calls a 3-line Python > > function in the runpy module. > > Instead of requiring a -z flag, why not have the interpreter peak at > the file to see if it starts with one of the ZIP magic numbers? > > That way it Just Works. I guess you wouldn't recognize a zip file if it hits you in the face. Literally. :-) Zip files don't start with a magic number. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
Crutcher Dunnavant On Jul 23, 2007, at 9:55 AM, "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > On 7/12/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: >> On 7/11/07, Andy C <[EMAIL PROTECTED]> wrote: >>> The good thing about this is that it's extremely simple -- basically >>> 20 lines of C code to add a -z flag that calls a 3-line Python >>> function in the runpy module. >> >> Instead of requiring a -z flag, why not have the interpreter peak at >> the file to see if it starts with one of the ZIP magic numbers? >> >> That way it Just Works. > > I guess you wouldn't recognize a zip file if it hits you in the face. > Literally. :-) > > Zip files don't start with a magic number. Don't they end with a sentinel? If so, what would be the difference? > > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) > ___ > Python-Dev mailing list > [email protected] > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/crutcher%40gmail.com ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
On 7/23/07, Crutcher Dunnavant <[EMAIL PROTECTED]> wrote: > > > Crutcher Dunnavant > > On Jul 23, 2007, at 9:55 AM, "Guido van Rossum" <[EMAIL PROTECTED]> > wrote: > > > On 7/12/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > >> On 7/11/07, Andy C <[EMAIL PROTECTED]> wrote: > >>> The good thing about this is that it's extremely simple -- basically > >>> 20 lines of C code to add a -z flag that calls a 3-line Python > >>> function in the runpy module. > >> > >> Instead of requiring a -z flag, why not have the interpreter peak at > >> the file to see if it starts with one of the ZIP magic numbers? > >> > >> That way it Just Works. > > > > I guess you wouldn't recognize a zip file if it hits you in the face. > > Literally. :-) > > > > Zip files don't start with a magic number. > > Don't they end with a sentinel? If so, what would be the difference? There's an ambiguity -- a Zip file could start with a Python (or shell, or Perl) script that bootstraps execution. This is used regularly. Changing the semantics just because the file *ends* with something funny sounds like asking for trouble. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
At 09:55 AM 7/23/2007 -0700, Guido van Rossum wrote: >On 7/12/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > > On 7/11/07, Andy C <[EMAIL PROTECTED]> wrote: > > > The good thing about this is that it's extremely simple -- basically > > > 20 lines of C code to add a -z flag that calls a 3-line Python > > > function in the runpy module. > > > > Instead of requiring a -z flag, why not have the interpreter peak at > > the file to see if it starts with one of the ZIP magic numbers? > > > > That way it Just Works. > >I guess you wouldn't recognize a zip file if it hits you in the face. >Literally. :-) > >Zip files don't start with a magic number. I've actually started on a patch that uses the standard import hooks to figure out how to import __main__ from sys.argv[0], if it's something that an import hook can be found for (otherwise, it falls back to normal behavior). At this point, the problem is that __main__ is a builtin module and already exists when this processing is being done, so trying to reload it in a straightforward way doesn't work. (Nor does using the standard -m logic.) If I can figure out how to work around that bit, we won't need a -z flag, which means a #! line for zipfiles is possible on 'nix, and we can support arbitrary import hooks for sys.argv[0]. (Assuming they're either built-in or registered via sitecustomize, that is.) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
At 10:34 AM 7/23/2007 -0700, Guido van Rossum wrote: >There's an ambiguity -- a Zip file could start with a Python (or >shell, or Perl) script that bootstraps execution. This is used >regularly. Changing the semantics just because the file *ends* with >something funny sounds like asking for trouble. Actually, it isn't, because you can't start a zipfile with a Python script. Lord knows I've *tried*, but the Python interpreter just won't accept arbitrary binary data as part of a script. :) Second, unless you somehow managed to overcome that little obstacle, you're not going to be trying to run the zipfile with the Python interpreter, anyway. Instead, the #! line (or .exe header on Windows) will be invoking whatever interpreter or program actually works for that file. Third, if you mistakenly pass an existing such zipfile to a new Python interpreter that supports zipfiles, and there's no __main__.py* file in it, you're just going to get a different error message than the syntax error you'd have received from an older Python.interpreter to run it with -- but otherwise no difference. In other words, AFAICT there's really no ambiguity here. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
On 23/07/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > Actually, it isn't, because you can't start a zipfile with a Python > script. Lord knows I've *tried*, but the Python interpreter just > won't accept arbitrary binary data as part of a script. :) That bit me a while back, hard enough that I thought of putting together a patch for it (probably just to stop processing the script at a NUL byte), but never did as I didn't think I could put a convincing enough case for it being *useful*. Anyway, I'd be happy enough with the -z patch as it stands, or if someone comes up with something better, that would suit me too... Paul. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] -z, -i and -m, maybe bug in runpy?
While trying to get my -z replacement patch to work, I stumbled across a bug in the -m implementation (and in runpy). It seems that when you run the code of a -m module, it is *not* run in the __main__ module namespace! So even though __name__=='__main__', globals() is not sys.modules['__main__'].__dict__. This seems wrong to me. Does anybody know why runpy doesn't actually run the code in the target module? One consequence of this is that the -i option is much less useful when you use -m, because the script's globals have disappeared before you get to the interpreter prompt. At this point, I've successfully gotten a -z replacement patch, except that it inherits this apparent bug from -m, which for a while led me to believe my patch was broken (when in fact it works fine, apart from inheriting the -m behavior). Does anybody know if this behavior is intended, and if so, why? And what are the consequences of changing/fixing it? ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Two spaces or one?
In PEP 9 there's a requirement that PEPs must follow the "emacs convention" of 2 spaces after a period. (I didn't know this was an emacs convention, I thought it was a convention of people who used typewriters.) I've tried hard to maintain this textual convention in my own PEPs, even though it's very unnatural to me. But I see from looking at the other PEPs that that this convention is very inconsistently enforced - some have it and some don't. Worse, I've had one person (who apparently wasn't aware of the rule) flag my use of extra space after a period as a bug in my PEP. (When I first learned to type, I used one space after a period. Then years later, someone convinced me that two spaces was the proper style and so I switched to that for a few years. But later I switched back because I realized that most modern typographical layout engines seem to calculate inter-sentence spacing properly when the number of space characters after a period is one. And in HTML [which is how most people view PEPs anyway] it doesn't matter since the browser is going to filter out the extra space anyway.) So if we're not going to enforce the rule consistently (and it seems as if we're not), can we then just remove it from PEP 9? I'm not saying that we should change the rule to one space, I'm suggesting that we just drop the requirement and let people use whatever they prefer. -- Talin ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
Just to update everyone on the status of this, the next thing on my list is to figure out the Windows build and set up the the file association in the installer. Actually, I should ask if there's anything else that I should pay attention to here, e.g. do I have to add an icon association for Windows or something like that? Is there any documentation like a wiki page on this? I looked at the README in the PC* directories and it doesn't seem to talk about the installer. Maybe it will become clearer when I get Visual Studio. Andy On 7/23/07, Paul Moore <[EMAIL PROTECTED]> wrote: > On 23/07/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > Actually, it isn't, because you can't start a zipfile with a Python > > script. Lord knows I've *tried*, but the Python interpreter just > > won't accept arbitrary binary data as part of a script. :) > > That bit me a while back, hard enough that I thought of putting > together a patch for it (probably just to stop processing the script > at a NUL byte), but never did as I didn't think I could put a > convincing enough case for it being *useful*. > > Anyway, I'd be happy enough with the -z patch as it stands, or if > someone comes up with something better, that would suit me too... > > Paul. > ___ > Python-Dev mailing list > [email protected] > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/andychup%40gmail.com > ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
New icons get added so rarely that each time it happens, Windows has changed enough to make the instructions invalid... I do remember creating icon associations for .py, .pyc, .pyo and .pyw, and separate "open" associations for these. IIRC the two associations are quite independent. Probably everything has changed though since we now use MSI. --Guido On 7/23/07, Andy C <[EMAIL PROTECTED]> wrote: > Just to update everyone on the status of this, the next thing on my > list is to figure out the Windows build and set up the the file > association in the installer. Actually, I should ask if there's > anything else that I should pay attention to here, e.g. do I have to > add an icon association for Windows or something like that? > > Is there any documentation like a wiki page on this? I looked at the > README in the PC* directories and it doesn't seem to talk about the > installer. Maybe it will become clearer when I get Visual Studio. > > Andy > > On 7/23/07, Paul Moore <[EMAIL PROTECTED]> wrote: > > On 23/07/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > > Actually, it isn't, because you can't start a zipfile with a Python > > > script. Lord knows I've *tried*, but the Python interpreter just > > > won't accept arbitrary binary data as part of a script. :) > > > > That bit me a while back, hard enough that I thought of putting > > together a patch for it (probably just to stop processing the script > > at a NUL byte), but never did as I didn't think I could put a > > convincing enough case for it being *useful*. > > > > Anyway, I'd be happy enough with the -z patch as it stands, or if > > someone comes up with something better, that would suit me too... > > > > Paul. > > ___ > > Python-Dev mailing list > > [email protected] > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: > > http://mail.python.org/mailman/options/python-dev/andychup%40gmail.com > > > -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Two spaces or one?
Talin <[EMAIL PROTECTED]> wrote: > > In PEP 9 there's a requirement that PEPs must follow the "emacs > convention" of 2 spaces after a period. (I didn't know this was an emacs > convention, I thought it was a convention of people who used typewriters.) If the PEP is displayed as HTML, then one or two spaces after a period in plain text might not matter; any browser that I've bothered to check visually merges space characters unless they are intermixed/replaced with non-breaking space ( ). If ReStructured Text converts to non-breaking space, then they matter. In terms of text text editing, I think that as long as one is consistant within a document, that's good enough. - Josiah ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
Andy C schrieb: > Just to update everyone on the status of this, the next thing on my > list is to figure out the Windows build and set up the the file > association in the installer. Actually, I should ask if there's > anything else that I should pay attention to here, e.g. do I have to > add an icon association for Windows or something like that? > > Is there any documentation like a wiki page on this? I looked at the > README in the PC* directories and it doesn't seem to talk about the > installer. Maybe it will become clearer when I get Visual Studio. It's all in Tools/msi/msi.py. Just look for the other extensions; the change should be fairly straight-forward. Regards, Martin ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Two spaces or one?
Talin schrieb: > In PEP 9 there's a requirement that PEPs must follow the "emacs > convention" of 2 spaces after a period. (I didn't know this was an emacs > convention, I thought it was a convention of people who used typewriters.) It's an Emacs convention in the sense that its auto-filling function expects that; it will not break lines after a period which is followed by a single space only. (These are the default settings, this being Emacs you can customize it.) Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
