[Patches] [ python-Patches-572796 ] Executable .pyc-files with hashbang

noreply@sourceforge.net noreply@sourceforge.net
Sun, 28 Jul 2002 04:39:39 -0700


Patches item #572796, was opened at 2002-06-23 18:42
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=572796&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Peter Åstrand (astrand)
Assigned to: Nobody/Anonymous (nobody)
Summary: Executable .pyc-files with hashbang

Initial Comment:
As an experiment, I've tested if it was possible to add
hashbang (like #!/usr/bin/python) to compiled
.pyc-files. The attached patched makes this possible. 

This can be useful when distributing applications as
bytecode. Currently, on a UNIX system, it's necessary
to make a wrapper script. 

I haven't considered portability issues with non-UNIX
platforms and things like that. Also, the hash and bang
may collide with the magic number. The patch is just a
proof-of-concept. 

I won't be surprised if you all think that this is a
bad idea, but I thought I should send the patch anyway.
Has this been discussed before?



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-07-28 13:39

Message:
Logged In: YES 
user_id=21627

Since nobody has spoken in favour of this patch, I'm
rejecting it.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-06-30 18:23

Message:
Logged In: YES 
user_id=21627

On Linux, you can also use

import imp,sys,string
magic = string.join(["\x%.2x" % ord(c) for c in
imp.get_magic()],"")
reg = ':pyc:M::%s::%s:' % (magic, sys.executable)
open("/proc/sys/fs/binfmt_misc/register","wb").write(reg)

to make the system recognize .pyc files (see Misc/NEWS).

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-06-23 18:51

Message:
Logged In: NO 

Well, there's this:

http://www.lyra.org/greg/python/#dev

Does that help?

(mwh, having a fight with sf's login system)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=572796&group_id=5470