briefcase
briefcase copied to clipboard
add hook to commands
My use case is the following: Qt and pyside has a resource system where the following command has to be called :
pyside2-rcc resources.qrc -o resources.py
Every time a ressource is changed, I need to run it.
So it would be cool to have the possiblity to add some "pre command" and "post command" hook.
Maybe something like this in the pyproject.toml :
[tool.briefcase.app.mycartable.hooks]
dev_pre = ["pyside2-rcc resources.qrc -o resources.py"]
or /and
[tool.briefcase.app.mycartable.hooks.linux]
dev_pre = ["pyside2-rcc resources.qrc -o resources.py"]
run_post=["some other command after briefcase run"]
If you are interested, maybe I could try to do it. By the way briefcase is very cool. By far the easier to cross package pyside app. thanks. Jimmy
Thanks for the suggestion, and for the kind words about Briefcase - glad you're enjoying it!
This is an interesting idea, and I can definitely see how an "additional processing" step may be necessary on some platforms. My question is whether the pyproject.toml
file to configure this. At the very least, writing executable commands in the configuration file is going to complex because of cross-platform concerns (although allowing for per-platform variants might mitigate that).
However, I have a larger usability concern. Based on your description, I'm guessing every Pyside app will need to run a similar "resource processing" step. If that's the case, then ideally a Pyside user wouldn't need to manually add those commands; it would "just happen" as a result of setting up your app as a Pyside app.
The complication here is that once the initial wizard has completed, the app template is completely agnostic on the framework being used, so we don't currently have a representation of the data you need to set up a Pyside-specific hook.
I can think of a couple of possible approaches:
Firstly, include hook script locations in the app template. The various commands would look for scripts in the generated app template directory (e.g., macOS/Hello World/pre-run.sh
) and execute them at the relevant times; if those scripts don't exist, they're ignored. If you had a Pyside app, you could either specify a custom app template that defined the relevant scripts, or manually add the scripts as part of the app development process.
A second approach would be to to treat framework support as a "plugin" activity. Briefcase would register a series of hooks (like pre-run
and post-create
); and plugins could then define handlers for those hooks. When you set up your project, you would include briefcase-pyside
in your development environment, which would register handlers for those hooks, and do the relevant processing. The hooks would have access to all the runtime information that briefcase has (like the current platform, app configuration data, etc), so you could end up with very sophisticated pre/post hooks, if needed.
Any thoughts about either of those approaches?
Hi, "Many" pyside user will need a "pre-run" but not necessary with those files, those commands or those names. So it's hard to anticipate.
About the first idea : I definitely prefer this one. I's simple and clear et very customisable. Let say a hook directory with files formatted with os and command names :
pyproject.toml
hooks/
all_pre_run.py
win_post_create.ps1
macos_pre_create.sh
linux_post_build.sh
suporting python script would give cross platform access and possibly access to briefcase api (to get runtime info) if possible.
About the second : I think a plugin system à la pytest would be great (with hooks and conftest) if needed but for now, I 'm not sure to need it, and I think it's over complicated considering what I want to achieve (and all the various commands that pyside user could run).