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

Command to run a command in a package virtualenv #434

Closed
pawamoy opened this issue Jun 24, 2020 · 10 comments
Closed

Command to run a command in a package virtualenv #434

pawamoy opened this issue Jun 24, 2020 · 10 comments

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Jun 24, 2020

How would this feature be useful?
It would be useful when one wants to play a bit with the internals/api of a package in a Python interpreter.

Describe the solution you'd like
Instead of creating a venv myself, and install for example aria2p and ipython inside it, I would like to use pipx directly. I already installed aria2p with pipx, injected ipython in its venv, and now I would like to run ipython in this venv.

Describe alternatives you've considered
Creating a venv myself, or manually activating the venv of the pipx package. We could also consider adding a shell command (to activate the venv) instead of another run command.

Do you think this is in the scope of pipx 🙂?
Thanks for the great project!

@itsayellow
Copy link
Contributor

One solution is to use the --include-apps option when you inject ipython into your aria2p venv. Then whenever you execute ipython, it would use the one inside your aria2p venv.

Would this work for you?

@pawamoy
Copy link
Contributor Author

pawamoy commented Jun 24, 2020

Not really, I also have ipython installed through pipx 😅

@itsayellow
Copy link
Contributor

So is the problem that you don't want aria2p installed with your normal ipython venv? Because a workaround would just be to pile everything you want into the same venv.

@pawamoy
Copy link
Contributor Author

pawamoy commented Jun 24, 2020

So is the problem that you don't want aria2p installed with your normal ipython venv

Hmmm, this could be a solution, yes. But I find it a bit redundant to install aria2p both in its own venv and in the ipython venv. I mean, more redundant than installing ipython both in its own venv and in the aria2p venv, because what matters here is the aria2p version I'm using, not the ipython one: I want to play with aria2p's api, the same api that is used when I call directly the script aria2p. Doing the opposite (what you suggest) would mean I have to remember to upgrade the injected aria2p in the ipython venv when I upgrade the main aria2p install, which, IIUC is not possible yet (#79).

@itsayellow
Copy link
Contributor

Upgrading! 👍 Yes that's a challenge for injected packages. Good point.

@pawamoy
Copy link
Contributor Author

pawamoy commented Dec 2, 2023

Hi @gaborbernat, is there a commit or PR you could reference?

@pawamoy
Copy link
Contributor Author

pawamoy commented Dec 2, 2023

Ah, I guess it's #563 🙂
Well, it kinda provides a workaround for my use-case, but being able to run commands inside venvs would still be useful I think.

@pawamoy
Copy link
Contributor Author

pawamoy commented Dec 2, 2023

To re-state the original use-case:

  • I have many tools that can be used as libraries, each installed in its own pipx venv
  • if I want to play with their API, I can inject ipython into each of these venvs
  • but then it's hard to call these injected ipython
  • the workaround suggested by @itsayellow is too install ipython in its own venv, and inject all the tools there as well
  • with not too many tools it's probably OK, but with more, that makes a polluted ipython venv, with risks of dep conflicts
  • also, while I can control the exact versions of tools in their own venvs, I cannot control their versions when they are injected in the ipython venv

I suppose there are other use cases where one would want to run an installed script in a given pipx venv, though I don't have any in mind.

Anyway that was just to provide feedback, feel free to keep this issue closed.

@gaborbernat
Copy link
Contributor

gaborbernat commented Dec 2, 2023

Sorry, didn't write, but IMHO this is out of scope for the project. Pipx environments are not meant to be changed by you, they are implementation details; as such, I'm -1 on allowing people to run custom commands in it. The only way these apps are meant to be used is through the console entry point we expose into your .local/bin. If you really must, you can find and open the python interpreter yourself, but because is discouraged, I would rather not make it easy.

@pawamoy
Copy link
Contributor Author

pawamoy commented Dec 2, 2023

I see, thank you for the explanation! 👍

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

No branches or pull requests

3 participants