This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Executable .pyc-files with hashbang
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: astrand, loewis, nobody
Priority: normal Keywords: patch

Created on 2002-06-23 16:42 by astrand, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pyc-hashbang.patch astrand, 2002-06-23 16:42 Proof-of-concept
Messages (4)
msg40394 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2002-06-23 16:42
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?

msg40395 - (view) Author: Nobody/Anonymous (nobody) Date: 2002-06-23 16:51
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)
msg40396 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-30 16:23
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).
msg40397 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-28 11:39
Logged In: YES 
user_id=21627

Since nobody has spoken in favour of this patch, I'm
rejecting it.
History
Date User Action Args
2022-04-10 16:05:26adminsetgithub: 36788
2002-06-23 16:42:59astrandcreate