conda / menuinst

Cross platform menu item installation
https://conda.github.io/menuinst/
BSD 3-Clause "New" or "Revised" License
36 stars 42 forks source link

provide no_console flag #87

Closed jaimergp closed 1 year ago

jaimergp commented 2 years ago

Currently there are several ways to add a shortcut:

In all cases, cwp.py will launch a subprocess with a patched PATH env var.

The difference between pyscript and pywscript is that they will use python.exe and pythonw.exe, respectively. PythonW has the property of not creating a CMD console to launch. However, when PythonW is also used as the subprocess executable, it will kill the UI window instantly.

This is happening to us at Napari, where we can use pyscript to launch the PyQT UI perfectly (but we end up with that ugly console in the background). pywscript as it is, will launch the app but it will flash and die instantly. We've found that the following combination results in a working UI with no background console: use pythonw to call cwp.py and launch a subprocess using the regular python.exe but with a CREATE_NO_WINDOW flag.

This is what this new option pywscript_no_console implements. Documentation should be added to the Wiki as well if this is merged as it is.

Instead of new pyscript derivative, I also thought of adding a configuration parameter cwp_flags. This will allow the user to specify extra CLI flags for cwp.py, but right now there's only one (introduced in this PR), so I don't think it's too useful.

I also changed the CLI parsing to use argparse instead of that sys.argv hack.