krobelus / git-branchstack

Efficiently manage Git branches without leaving your local branch
https://git.sr.ht/~krobelus/git-branchstack
MIT License
53 stars 2 forks source link

pipx installation #6

Closed halostatue closed 2 years ago

halostatue commented 2 years ago

To avoid the frequent breakage of Python on Homebrew, I started using pipx, which installs each package in its own venv.

It would be great to list this as an alternative installation mechanism for git-branchstack:

pipx install git-revise@git+https://github.com/mystor/git-revise.git@06e9126cc9f39c48486792a25999d3b8fc1caacd
pipx install git-branchstack
krobelus commented 2 years ago

pipx install git-revise@git+https://github.com/mystor/git-revise.git@06e9126cc9f39c48486792a25999d3b8fc1caacd pipx install git-branchstack

Installing both in isolation means that the runtime dependency (git-revise python module) is not available, see the log below.

Note that if you install git-revise normally, you can directly call ./git-branchstack (e.g. with a symlink) without installing it.

To avoid the frequent breakage of Python on Homebrew, I started using pipx, which installs each package in its own venv.

BTW why does the breakage happen? Note that git-revise doesn't have any dependencies, so it should be fairly stable. Or is it because of Python version bumps?

I'm sure there's a way to solve this with pipx, but I don't know how? PYTHONPATH would work but that seems overkill. I don't want to vendor the dependency. BTW why didn't they call it pipy, that's obviously the superior name since there's PyPI

$ HOME=$PWD pipx install git-revise@git+https://github.com/mystor/git-revise.git@06e9126cc9f39c48486792a25999d3b8fc1caacd
  installed package git-revise 0.6.0, Python 3.9.7
  These apps are now globally available
    - git-revise
⚠️  Note: '$PWD/.local/bin' is not on your PATH environment variable. These apps will not be globally
    accessible until your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's
    config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨
$ HOME=$PWD pipx install git-branchstack
  installed package git-branchstack 0.1.0, Python 3.9.7
  These apps are now globally available
    - git-branchstack
    - git-branchstack-pick
⚠️  Note: '$PWD/.local/bin' is not on your PATH environment variable. These apps will not be globally
    accessible until your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's
    config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨
$ .local/bin/git-branchstack
Traceback (most recent call last):
  File "$PWD/.local/bin/git-branchstack", line 5, in <module>
    from gitbranchstack.main import main
  File "$PWD/.local/pipx/venvs/git-branchstack/lib/python3.9/site-packages/gitbranchstack/main.py", line 10, in <module>
    import gitrevise
ModuleNotFoundError: No module named 'gitrevise'
halostatue commented 2 years ago

Good point. I thought you might be using git-revise via a command-line interface, so I didn’t think of that. However, this would work:

pipx install git-branchstack
pipx inject git-branchstack --include-apps git-revise@git+https://github.com/mystor/git-revise.git@06e9126cc9f39c48486792a25999d3b8fc1caacd

Do a pipx uninstall git-revise, first.

halostatue commented 2 years ago

And the breakage is frequent updates of Python. When that happens I can do a pipx reinstall-all which rebuilds the venvs with the new Python binary and keeps isolation. As I’m not really a Python developer, I don’t really want to do --user all the time, and with the updates of Python, my installed tools kept breaking because the results of pip install … (not pip install --user …) were moved around all the time.

krobelus commented 2 years ago

Sorry for the delay, and thanks for digging up that command. pipx looks really useful. I have included it in the README in 8c982a4c3d2de4b3b6f9538dfcdc199e72d8a91b