pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Support for `pipx inject <package> -r <requirements-file>`

Open jamesmyatt opened this issue 2 years ago • 3 comments

How would this feature be useful?

I'd like to be able to inject packages into a package environment from a standard pip requirements file and have them registered individually as "injected" dependencies, e.g. for list --include-injected and upgrade(-all) --include-injected.

Alternatives listed below all have deficiencies in some way.

This is a different take on https://github.com/pypa/pipx/issues/359 and https://github.com/pypa/pipx/issues/357 (etc).

Describe the solution you'd like

As mentioned by @funkyfuture in https://github.com/pypa/pipx/issues/359#issuecomment-593279235.

pipx inject <package> -r <requirements-file>

Describe alternatives you've considered

The standard solution below is OK, but doesn't register the additional packages as "injected". Hence they're invisible to commands that support --include-injected.

pipx install <package>
pipx runpip <package> install -r <requirements-file>

The following solution by @Sispheor and @hanfried doesn't work on Windows, may miss edge-cases, and is generally clumsy.

cat <requirements-file> | sed -e 's/#.*//' | xargs pipx inject <package>

jamesmyatt avatar Feb 02 '23 14:02 jamesmyatt

I was able to just now do:

pipx install nox --pip-args "-r requirements.txt"

Where requirements.txt had the pinned dep I wanted. pipx runpip nox freeze confirmed the specified version was installed.

JamesParrott avatar Feb 07 '24 13:02 JamesParrott

@JamesParrott . I think that's equivalent to the first alternative I posted above. Can you check with pipx list --include-injected whether the additional dependencies are visible as "injected" packages, please?

jamesmyatt avatar Feb 07 '24 14:02 jamesmyatt

They're not listed as injected - you're right.

JamesParrott avatar Feb 07 '24 15:02 JamesParrott