Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse 'pipx run' input and infer the app name like 'pipx install' #854

Open
aaronsteers opened this issue Jun 18, 2022 · 7 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@aaronsteers
Copy link

How would this feature be useful?

This would make pipx run immensely more user friendly and easier to type without resorting to a readme or scanning the --help for the correct run syntax.

Background

Given an app called tap-mysql currently, pipx run tap-mysql --help works great! It knows that the plugin's name is tap-mysql and it attempts to run a command with that same name (tap-mysql --help in this example),

Given an a more complex pip_url (like tap-mysql==1.4 or git+https://github.com/singer-io/tap-mysql.git), could pipx doesn't use the detected package name to attempt the same. Instead, the package is installed and then the command will immediately fail.

$ pipx run tap-mysql --help
usage: tap-mysql [-h] -c CONFIG...
... # works perfectly
$ pipx run tap-mysql==1.17.5 --help
'tap-mysql==1.17.5' executable script not found in package 'tap-mysql==1.17.5'. Available executable scripts: tap-mysql

So in theory, we could put those two things together and let this work out of box?: pipx run <any_pip_url> --help

Describe the solution you'd like

The requested feature improvement would be to use the detected package name as the app name if --spec is not detected and if the argument passed to pipx run was a complex pip_url, such as a git ref or a version-pinned ref.

Already pipx does have the logic to detect package name, and pipx run already accepts simple package names without having to separately pass the app name.

pipx run tap-mysql --help                                              # already works today
pipx run tap-mysql==1.17.5 --help                                      # would be new
pipx run git+https://github.com/singer-io/tap-mysql@main.git --help    # would be new

Describe alternatives you've considered

The workaround is to explicitly send the executable name and pip URL separately using pipx run --spec <pip_url> <app_name>. However, this is not very portable and since most pipx commands do not require remembering the --spec.

Instead of running like this:

pipx run git+https://github.com/singer-io/tap-mysql.git --help

or

pipx run tap-mysql==1.0.5 --help

We would need to add tap-mysql at the end also.

pipx run --spec=git+https://github.com/singer-io/tap-mysql.git tap-mysql --help
@uranusjr
Copy link
Member

This doesn’t need an option at all, pipx could use the same name-inferring logic in pipx install for this.

@uranusjr uranusjr changed the title Option for pipx run to infer a default app name when passed a complex pip_url Parse 'pipx run' input and infer the app name like 'pipx install' Aug 14, 2022
@uranusjr uranusjr added the enhancement New feature or request label Aug 14, 2022
@konstantinos-null
Copy link

Hey pipx team, is this issue still active? I was trying to recreate it using something like:

pipx run ansible-lint==6.8.1

and

pipx run ansible-lint

but both commands are running normally. Am I doing something wrong with trying to check the issue?

Thanks in advance.

@dukecat0
Copy link
Member

pipx run ansible-lint==6.8.1

The above command actually works, but the following doesn't:

pipx run git+https://github.com/singer-io/tap-mysql@main.git --help

@aaronsteers
Copy link
Author

aaronsteers commented Oct 18, 2022

Based on the comments from @meowmeowmeowcat and others, I've confirmed that this issue seems specific to git refs.

aj@ajs-macbook-pro ~ % pipx --version
1.1.0
aj@ajs-macbook-pro ~ % pipx run git+https://github.com/ansible/ansible-lint.git --version
pipx will only execute apps from the internet directly if they end with '.py'. To run from an SVN, try pipx
--spec URL BINARY
aj@ajs-macbook-pro ~ %

Version-pinned refs seem to resolve the app name without issue.

@konstantinos-null
Copy link

So, I've been looking into the updated info and trying to understand the whole issue and try creating a proper approach.
Its my first time trying to contribute actual code so I'm kinda inexperienced on that part.

My understanding currently for this issue is that with --spec it downloads and runs the application with no problems whatsoever but when adding --spec it will not use the same argument(from the url)t to determine the app name so we need to make it use that argument as the app name too, correct?

@dukecat0
Copy link
Member

We should allow users to run the app without --spec if the app name provided is an SVN URL, so a command like pipx run git+https://github.com/ansible/ansible-lint.git --version can be run successfully. After auto name inferring, it should get ansible-lint and use this name to run the app.

konstantinos-null added a commit to konstantinos-null/pipx that referenced this issue Oct 19, 2022
@gaborbernat gaborbernat reopened this Dec 2, 2023
@gaborbernat
Copy link
Contributor

PR welcome.

@gaborbernat gaborbernat added the help wanted Extra attention is needed label Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants