linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.75k stars 99 forks source link

Is there a way to show a message to the user during the environment bootstrapping phase? #246

Open itsthejoker opened 11 months ago

itsthejoker commented 11 months ago

Hi, all! I really enjoy working with Shiv, and have most recently used it to bundle some internal developer tooling for my team. After an update, there's a several-second delay while it unpacks the updated environment (that's just part of life), and I'd like to show a message to the console on first run that is essentially just "Setting up environment..." that disappears when the bootstrap section is done.

Is this possible? If so, can you point me in the right direction as to how I might be able to implement this into my project?

Cheers!

lorencarvalho commented 9 months ago

Hi @itsthejoker,

Yes! The "--preamble" argument should work nicely for what you want. This basically allows you to ship any executable (or Python script) with your pyz, and executes it during the bootstrap phase :)

The docs can be found here: https://shiv.readthedocs.io/en/latest/?badge=latest#preamble

itsthejoker commented 9 months ago

Hi @lorencarvalho! My issue is in the docs: "(after extracting dependencies but before invoking an entry point / console script)." I want to display a notice to the user while dependencies are being extracted, as this can take a bit for my shiv app.

gleesonger commented 6 months ago

I have a very similar need as OP.

In my case, I have a GUI application which is launched with "pyw" on windows, so there is no console interface. The end user launches the program and then needs to wait several seconds before they see anything. During this time, they are wondering if they correctly launched the program or not.

Having the ability to run code before any unpacking would be useful as an interface in base Python could be shown before the dependencies become available.