You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zipapp creates executable files with wrong permissions bits #96867
Owing to the fact that open() has no flags field for marking a file as executable, and doing that after the fact is difficult (since it involves playing around with umask), the current implementation of zipapp uses the following code to attempt to set the file executable:
OK, thanks. I don't propose to go there with the initial implementation. If it's a problem in practice, someone can raise a bug and we'll fix it then. (I've never seen actual Python code in the wild that does all of that...)
This is a problem in practice for us.
We're trying to replace the C version of Cockpit with a Python zipapp, and the file gets created with permissions that allow the current user to run it, but won't allow the file to be installed in /usr/bin so everyone can run it.
We can work around it easy enough — chmod +x in the Makefile after we call zipapp, but this is a bug in zipapp that really ought to be fixed.
For what it's worth, I think the os.fdopen() approach originally proposed by "dholth" is the best one.
See discussion on #151970 - the correct (IMO) approach here is to do what chmod +x does, but I don't want to maintain code for that in zipapp itself, so it would need a suitable public API in another stdlib module (os, pathlib or shutil seem like good candidates to me).
Activity
kilitary commentedon Feb 28, 2026
yuanx749 commentedon Jul 23, 2026
Friendly ping: PR #151970 is awaiting review.
pfmoore commentedon Aug 2, 2026
See discussion on #151970 - the correct (IMO) approach here is to do what
chmod +xdoes, but I don't want to maintain code for that inzipappitself, so it would need a suitable public API in another stdlib module (os,pathliborshutilseem like good candidates to me).