HPI icon indicating copy to clipboard operation
HPI copied to clipboard

hpi install/update command

Open seanbreckenridge opened this issue 2 years ago • 2 comments

Had an idea to make the install process perhaps easier, or at least automate some things - thought I'd leave it here -- personally I feel the most convenient way to use is through local editable installs, especially if someone is installing multiple (e.g. yours and mine) but I can imagine setting that up and managing updating it by git pulling can perhaps feel tedious for some users

So, this could add (one or two commands, or perhaps behind a click.group) to help manage that

Of course this isn't required, but for people who aren't as familiar with pip, it would automate some of the process.

Would define a directory like ~/.local/share/HPI where the repos sit and then running something like:

hpi repo install karlicoss/HPI clones your repo and pip install -es it hpi repo install seanbreckenridge/HPI installs mine into another directory there (could manage name conflicts and the like)

hpi repo install could also probably just default to karlicoss/HPI

this would just for the most part subprocessing the pip/git commands.

And then, running hpi repo update would cd to those and git pull, printing updates to your console with git commit info

It does seem a bit like a monorepo command/plugin system like oh-my-zsh or doom something -- Not advocating for that, this is just to manage the editable installs. I guess they have the update commands for a reason, because would decrease the barrier to entry for someone not having to manage the editable installs or git

This would also be accessible by just doing pip install HPI, (which then would be uninstalled and the editable version would be reinstalled, which is fine if we're just execing a command like pip uninstall -y HPI && pip install -e /path/to/local/clone), and then let the user maintain local directories instead of the pypi installed HPI, so the instructions for an editable install could just be:

pip install HPI
hpi repo install

and then periodically

hpi repo update

which could loop over my.__path__, checking if a .git directory exists relative to it to update by git pulling

In [1]: import my

In [2]: my.__path__
Out[2]: _NamespacePath(['/home/sean/Repos/HPI/my', '/home/sean/Repos/HPI-fork/my'])

Can work on this if its something youre interested in adding

seanbreckenridge avatar Oct 29 '21 20:10 seanbreckenridge

hpi repo install /path/to/local/clone

would be nice as well, allows you to place it wherever you want and is more flexible than just forcing a specific directory

Should still definitely document the manual version (pip install -e /path/), this is just to help users who may have trouble with that

seanbreckenridge avatar Oct 29 '21 20:10 seanbreckenridge

I guess related to https://github.com/karlicoss/HPI/issues/12

Yeah, good idea! I guess my only worry is that implementing it properly is going to be tricky, essentially it's a bit part of the plugin system. But if you wanna give it a go, would be cool! I'd try searching for something existing first, although last time I did, wasn't very fruitful sadly.

Btw, one way to get a lot of functionality for free is maybe using git submodules? E.g. ~/.local/share/HPI could be a git repository, and karlicoss/HPI, seanbreckenridge/HPI would be submodules. Then it would be possible to do bulk operations, atomic updates/rollbacks etc. Not sure if there is some prior art, so just throwing in the idea, maybe it doesn't work well.

karlicoss avatar Oct 31 '21 18:10 karlicoss

tried to implement some sort of this but ended up just spinning off into a a separate, generic project: clone-repos

Felt as if there are just too many edge cases and probably isnt worth the maintenance cost here

I have two clone-repos config files which let me manage hpi installs/updates:

https://github.com/seanbreckenridge/dotfiles/blob/master/.config/clone-repos/hpi-clone-repos.yaml https://github.com/seanbreckenridge/dotfiles/blob/master/.config/clone-repos/update-forks.yaml

one that installs stuff and another that git pull upstream masters:

$ clone-repos ~/.config/clone-repos/update-forks.yaml           
HPI-karlicoss: target /home/sean/Repos/HPI-karlicoss already exists
HPI-karlicoss: running preinstall 'git pull'
Already up to date.
HPI-karlicoss: running postinstall 'git pull upstream master'
From https://github.com/karlicoss/HPI
 * branch            master     -> FETCH_HEAD
Already up to date.
HPI-karlicoss: running postinstall 'git push'
Everything up-to-date
promnesia-fork: target /home/sean/Repos/promnesia-fork already exists
promnesia-fork: running preinstall 'git pull'
Already up to date.
promnesia-fork: running postinstall 'git pull upstream master'
From https://github.com/karlicoss/promnesia
 * branch            master     -> FETCH_HEAD
Already up to date.
promnesia-fork: running postinstall 'git push'
Everything up-to-date

Dont think I'm going to work on this anytime soon as I have a good enough solution, so will close

seanbreckenridge avatar Jan 13 '23 19:01 seanbreckenridge