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

How to initialise an empty venv with no app? #920

Closed
robinbowes opened this issue Nov 30, 2022 · 5 comments
Closed

How to initialise an empty venv with no app? #920

robinbowes opened this issue Nov 30, 2022 · 5 comments

Comments

@robinbowes
Copy link

How would this feature be useful?

I have a library package, and an app that uses the library package. Both are local-only, ie. I install them with pip install /path/to/library and pip install /path/to/app

I want to install app with pipx, but if I run pipx install /path/to/app it fails because library is not available.

I can't see how I can install library into the app venv before installing app.

Describe the solution you'd like

One possible workflow might be:

  • create an empty venv with a specified name
  • inject any dependencies into the venv
  • inject the app into the existing venv, using --include-apps to create symlink(s) for the app into $HOME/.local/bin

In my use-case:

  • pipx init foo
  • pipx inject foo /path/to/library
  • pipx inject --include-apps foo /path/to/app

So, what I need is the some command to create an empty venv into which I can inject dependencies and apps (the pipx init foo in the example above)

Describe alternatives you've considered
I have hacked a solution like this:

  • Install an arbitrary app to create a venv (I used cowsay)
  • Inject library into the cowsay venv
  • Inject app into the cowsay venv with --include-apps

app is now available

Suggestions for better ideas would be much appreciated.

@uranusjr
Copy link
Member

This sounds like a packaging issue in you app. Python packages shouldn’t require another package to be present during installation, only when the package code is actually run. While pre-installation injection may be a good feature to have, this would not be a use case for it.

@robinbowes
Copy link
Author

Python packages shouldn’t require another package to be present during installation, only when the package code is actually run

I'm not sure I agree with that. In my experience, when I install a package (local, or remote) it also makes sure any packages required by that package are installed, ie. those listed in the install_requires section of setup.cfg. The install will fail if those dependencies are not available.

@robinbowes
Copy link
Author

Looking at the source, it seems that a relatively easy way to achieve this would be to add an option to the inject command which creates the named package if it does not exist, installs the provided dependencies, and doesn't exit with an error if no app is installed. Something like:

pipx inject --create app dep1 dep2
pipx inject --include-apps app

I also tried specifying the deps with --pip-args , but that didn't work:

pipx install --pip-args="/path/to/library" /path/to/app
Cannot determine package name from spec '/path/to/app'.
Check package spec for errors.

@dukecat0
Copy link
Member

Maybe the --preinstall feature added in #900 can help in this case?

@gaborbernat
Copy link
Contributor

Maybe the --preinstall feature added in #900 can help in this case?

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

4 participants