coconut icon indicating copy to clipboard operation
coconut copied to clipboard

Coconut is incompatible with the zipapp module

Open yggdr opened this issue 2 years ago • 2 comments

Part of coconut's current header contains a check for a __init__.py file in the executed python file's directory. That check uses os.listdir which cannot operate within a zippapp. It is a known issue for zippapps to not be able to read files and directories like you could if you simply execute a python script, or a directory (using __main__.py). Tools like https://github.com/linkedin/shiv seem to circumvent this by extracting the zipapp before execution.

I'm not sure this is easily fixable, but since I just racked my brain for an hour wondering why this suddenly stopped working compared to older coconut versions, maybe a warning could be added to the docs or faq? :)

yggdr avatar Feb 18 '23 23:02 yggdr

I think that you should be able to make this work if you compile everything with --stand-alone.

evhub avatar Feb 19 '23 08:02 evhub

After a few quick tests, this indeed seems to be working, at the cost of tripling the resulting build's size. But I think can live with that for now :)

yggdr avatar Feb 19 '23 21:02 yggdr