pipx
pipx copied to clipboard
Support for `pipx inject <package> -r <requirements-file>`
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>
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 . 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?
They're not listed as injected - you're right.