enchantment: Register entry points
After #524 and https://github.com/ywangd/stash/issues/531 I propose to add 2 features
- Propose user to create/update stash Pythonista action shortcut on
get-stashcomplete - Update
bin/pip.pyto handle insallable packages entry points in `Documents/bin'
it can be solved with .egg-info\entry_points.txt, it looks like
[console_scripts]
entry-name = package_name.__main__:main
The idea is wrap entries in .sh or .py files automatically by stash.pip and place it in Documents/bin/entry-name.sh, like PC interpreter versions do
Propose user to create/update stash Pythonista action shortcut on get-stash complete
We offer this via the easy_config command. Opening that tool automatically would be a good idea, but I think we generally want the user to first force-quit and restart StaSh before we run StaSh in any capacity in order to deal with any cache-related weirdness. Just adding the shortcut would work, of course, too. But duplicating functionality already elsewhere present is always suboptimal, as it could lead to two similar actions with different behavior down the line.
Update bin/pip.py to handle insallable packages entry points in `Documents/bin'it can be solved with .egg-info\entry_points.txt, it looks like [console_scripts] entry-name = package_name.main:main
We already do this, I think. I recall adding this feature a couple of years ago, although the entrypoints are stored in ~Documents/stash_extensions/bin/ (or some similar path). The reason we are not directly adding them to Dcouments/bin is that we don't exclusively manage that directory. Some users may have their own scripts (either custom commands or completely unrelated to StaSh) in that directory and it would suck if we accidentally overwrote something important, wouldn't it ;)
Ah, found it. This should have been implemented by #226 and #326.
Propose user to create/update stash Pythonista action shortcut on get-stash complete
We offer this via the
easy_configcommand. Opening that tool automatically would be a good idea, but I think we generally want the user to first force-quit and restart StaSh before we run StaSh in any capacity in order to deal with any cache-related weirdness. Just adding the shortcut would work, of course, too. But duplicating functionality already elsewhere present is always suboptimal, as it could lead to two similar actions with different behavior down the line.Update bin/pip.py to handle insallable packages entry points in `Documents/bin'it can be solved with .egg-info\entry_points.txt, it looks like [console_scripts] entry-name = package_name.main:main
We already do this, I think. I recall adding this feature a couple of years ago, although the entrypoints are stored in
~Documents/stash_extensions/bin/(or some similar path). The reason we are not directly adding them toDcouments/binis that we don't exclusively manage that directory. Some users may have their own scripts (either custom commands or completely unrelated to StaSh) in that directory and it would suck if we accidentally overwrote something important, wouldn't it ;)Ah, found it. This should have been implemented by #226 and #326.
- I was sure ``easy config
adds an action toeasy configitself, not tostash` - Hm, but #524 uses common
pip, seem like #226 and #326 would not work - We can place installed entry-points to some other dir like
site-packages/binor even~/bin
I will explore #226 and #326
@bennr01
Aha, in easy_config it is not done, In addition, in #524 PR, I have already added support for __main__.py so easy_config should also be updated. I’ve already partially written this, so I think I’ll add the action creation as a separate command and import it into easy_config
@ui.in_background
def add_editor_action():
"""
adds an editor action to the 'wrench' menu in the editor which
launches launch_stash.py
"""
mv = cfg_view # [global] the main view
mv.ai.start()
try:
lsp = "/launch_stash.py" # TODO: auto-detect
paa.add_action(
lsp,
"monitor",
"000000",
"StaSh",
)
paa.save_defaults()
finally:
mv.ai.stop()
#326 already replaced by common pip and works fine
I will explore #226 and try to add this possibility to #524
I was sure ``easy configadds an action toeasy config
itself, not tostash`
It should add an action to launch StaSh as an action in the pythonista editor menu. Is that not what you are asking, or am I misunderstanding something?
Hm, but pythonista>=3.4/py>=3.10: Refactoring, removing deprecated requirements, updating for #524 uses common pip, seem like https://github.com/ywangd/stash/pull/226 and https://github.com/ywangd/stash/pull/326 would not work
I have yet to checkout that PR, it's quite big and I haven't had time yet, sorry. Yes, both PRs I've linked would only work with StaSh pip. I am not sure if we could even support the regular pip like the StaSh pip.
Okay I also found that #526 with common pip already register entry points in site-packages/bin so the only think we should do is allow to use it
Propose user to create/update stash Pythonista action shortcut on get-stash complete
- added
bin/pinstash.py, updatedbin/easy_config
Update bin/pip.py to handle insallable packages entry points in `Documents/bin'
site-packages/binconsole scripts support added to #524, that approach is more native for python environment tree