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

Run console scripts whose name doesn't match package name #725

Closed
tusharsadhwani opened this issue Aug 15, 2021 · 10 comments · Fixed by #733
Closed

Run console scripts whose name doesn't match package name #725

tusharsadhwani opened this issue Aug 15, 2021 · 10 comments · Fixed by #733

Comments

@tusharsadhwani
Copy link
Contributor

For eg:

$ pipx run textflip            
'textflip' executable script not found in package 'textflip'. Available
executable scripts: flip

So it does know about the script named flip, but I can't seem to figure out how to make it run that.

I've tried doing:

  • pipx run textflip.flip
  • pipx run textflip --spec flip
  • pipx run textflip flip etc.

None of these seem to work, and I can't seem to find the relevant documentation.

@tusharsadhwani
Copy link
Contributor Author

tusharsadhwani commented Aug 15, 2021

Also, for whatever reason, pipx run textflip.flip seems to be translated into pipx run textflip-flip, which I don't think would ever be what I intended to do. Is that intended behaviour?

@cs01
Copy link
Member

cs01 commented Aug 15, 2021

Try moving the spec argument. It’s being interpreted as an argument to the program you are running.

pipx run --spec PACKAGE APP

@tusharsadhwani
Copy link
Contributor Author

tusharsadhwani commented Aug 15, 2021

$ pipx run --spec=textflip flip hello
oןןǝɥ

Yup, that does work. But it feels really unintuitive to me, the --spec param name, and the fact that the package name is being passed as an optional parameter and the console_script name is being passed as the default argument. I would assume it would be the other way around.

Something like:

$ pipx run --script=flip textflip

And pipx run textflip.flip would probably be the most ideal.

@uranusjr
Copy link
Member

The syntax you suggested is not possible since textflip.flip is a valid package name.

@haakenlid
Copy link

Maybe the error message should explain that you can run pipx --spec textflip flip here?

$ pipx run textflip            
'textflip' executable script not found in package 'textflip'.
Available executable scripts:
    'flip' - usage: 'pipx run --spec textflip flip [arguments?]'

And in cases where there's a single executable, but with a different name than the package (usually a shorter command name for convenience), the user's intention is clearly to run that one. Maybe pipx could just run textflip.flip in this case?

@uranusjr
Copy link
Member

uranusjr commented Sep 9, 2021

An error message improvement would definitely be nice.

And in cases where there's a single executable, but with a different name than the package (usually a shorter command name for convenience), the user's intention is clearly to run that one. Maybe pipx could just run textflip.flip in this case?

Makes sense to me (if we add a line reminding the user what command is actually being invoked). Fancy a contribution?

@tusharsadhwani
Copy link
Contributor Author

Some comments for the future: Maybe some extra metadata could be added into pyproject.toml to tell it what the default runnable module is inside this package. If unspecified the top level package is taken.

@tusharsadhwani
Copy link
Contributor Author

Fancy a contribution?

I could take it up if you want!

@uranusjr
Copy link
Member

uranusjr commented Sep 9, 2021

Maybe some extra metadata could be added into pyproject.toml to tell it what the default runnable module is inside this package.

There’s already a mechanism for that introduced in #615. For a package named foobar, the package author can define a pipx.run entry point named foobar (same name as the package) and pipx will pick it up as the default command. Then you’re free to name your console_scripts whatever you want.

I could take it up if you want!

Go ahead!

@cs01
Copy link
Member

cs01 commented Sep 9, 2021

I just did a quick search from my phone, but didn’t see it in the docs — is pipx.run captured in our documentation anywhere? We should add a section dedicated to adding pipx support for one’s package and add that to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants