pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Add pipx install github pull request support

Open glensc opened this issue 3 years ago • 12 comments

How would this feature be useful?

pipx is for end users. end users typically don't understand how to figure out repo and branch of a pull request

Describe the solution you'd like

pipx install https://github.com/pypa/pipx/pull/794

Describe alternatives you've considered

The alternative, the current is to:

  1. open pr
  2. figure out source repo
  3. figure out branch name
  4. build git+https url
  5. pipx install that url
  • https://pypa.github.io/pipx/#installing-from-source-control

and even advanced users have trouble doing that:

pipx install git+https://github.com/meowmeowmeowcat/pipx@fix-#781

oh, glad I picked that example. some shells may need to deal with escapes, like # for UNIX, ^ for windows

also, once the PR is merged, and the branch deleted the branch name option won't work, would need to use git hash of the last commit or merge commit.

for initial implementation having support for open PR's would be already big step forward.

glensc avatar Feb 14 '22 07:02 glensc

Why would an end user want to install from a pull request? This seems like an exceedingly rare use case.

cs01 avatar Feb 16 '22 14:02 cs01

developer: can you test this fix from this pull request? user: ??????

glensc avatar Feb 16 '22 16:02 glensc

Why would an end user want to install from a pull request? This seems like an exceedingly rare use case.

@cs01 This would be incredibly helpful. Here's an example:

https://github.com/python-poetry/poetry/pull/4852#issue-1066910051

Install with pipx:

pip install pipx
pipx install --suffix=@pyenv 'poetry @ git+https://github.com/finswimmer/poetry.git@proof-of-concept-pyenv'
poetry@pyenv --version

When there's an bug or improvement, this can be used to get the users in the issue to test the pull request easily.

This saves a ton of effort. gh pr checkout has a similar utility.

I'm stunned this doesn't already exist. 🤷 I'm fine with doing it manually in the mean time by hand, but when reviewing lots of PRs this would save time.

Edit: NPM / yarn has a convention for this at https://stackoverflow.com/a/36743127/1396928

tony avatar Mar 14 '22 11:03 tony

The pull/ID/head is not npm specific, it's just a git ref, however it does not work:

WARNING: Did not find branch or tag 'pull/838/head', assuming revision or ref.

Perhaps that is the first thing to resolve.

➜ pipx install --suffix=@pr 'git+https://github.com/Taxel/PlexTraktSync@pull/838/head'
⣟ determining package name from 'git+https://github.com/Taxel/PlexTraktSync@pull/838/head'
  WARNING: Did not find branch or tag 'pull/838/head', assuming revision or ref.
  error: subprocess-exited-with-error

  × git checkout -q pull/838/head did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error: pathspec 'pull/838/head' did not match any file(s) known to git
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git checkout -q pull/838/head did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Cannot determine package name from spec 'git+https://github.com/Taxel/PlexTraktSync@pull/838/head'. Check package
spec for errors.

glensc avatar Mar 14 '22 12:03 glensc

Update: This usage works:

➜ pipx install --suffix=@pr 'git+https://github.com/Taxel/PlexTraktSync@refs/pull/838/head'
  installed package PlexTraktSync 0.18.0.dev0 (PlexTraktSync@pr), installed using Python 3.10.2
  These apps are now globally available
    - plextraktsync@pr
done! ✨ 🌟 ✨

But projects need to be installable from git branch:

  • https://github.com/Taxel/PlexTraktSync/pull/838

glensc avatar Mar 14 '22 12:03 glensc

@glensc Perhaps make a PR to add it to README / docs and see what the feedback is? I think others would find it helpful

tony avatar Mar 14 '22 12:03 tony

As a user myself, I'm a bit confused why I can't just run something like:

pipx install git+https://github.com/simons-public/protonfixes

when doing it with pip3 would normally be enough otherwise :/

ThisNekoGuy avatar Apr 19 '22 17:04 ThisNekoGuy

@gaborbernat your last message is truncated (or not formatted properly)

this is what I see

image

glensc avatar Jan 24 '24 00:01 glensc

While this is doable, would require us integrating against the GitHub API, which makes me nervous because then tomorrow a GitLab user would show up, and where would that end? As such, I'm currently -0.1 on doing this.

As a user myself, I'm a bit confused why I can't just run something like:

pipx install git+https://github.com/simons-public/protonfixes

This works and is not Git server dependent.

gaborbernat avatar Jan 24 '24 01:01 gaborbernat

What I see what needs to be done here is to document this experience:

  • https://github.com/pypa/pipx/issues/812#issuecomment-1066727490

and by "But projects need to be installable from git branch" I mean that I needed to make changes in code not to rely on CI part that generated version, i.e. version would have some default.

glensc avatar Jan 24 '24 06:01 glensc

i also found need to use --force flag to be able to reinstall from same pr, if it had new commits. so maybe pipx side could improve that it can detect that automatically. it does save some repo metadata, so if that changes, allow reinstall without force warning?

glensc avatar Jan 24 '24 06:01 glensc

here's more minimal changes needed to be able to install from source:

  • https://github.com/glensc/python-pytrakt/pull/37

it relied CI to fill __version__, so that was not installable, so used value in source repo that would also be a valid version

glensc avatar Jan 24 '24 07:01 glensc