Use python from virtualenv's bin directory when executing commands #5107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are executing python commands like
python /path/to/bin/command
Sometimes it gives a non-deterministic behaviour.
Like using pip from the virtualenv in the first build
and using pip from the global installation other times.
Commands like sphinx-build and mkdocs have an
console_scripts
entrypoint and shouldn't be a problem.
Now we are running the commands like
/path/to/bin/virtualenv/python -m pip install ...
, which gives a deterministic behaviour in every build.I notice this problem while implementing #5006.
When calling the
pyhton /path/to/pip list
command it gives an error (pypa/pip#5373), and when calling/path/to/pip list
it lists only the local packages, and in the second build/path/to/pip list
list only the global packages. With this fix,/path/to/python -m pip list
list global and local packages (in every build) as the docs say.I'm not sure about conda, but I think we have a command that uses pip there. But first I'd like to have some opinions here. And maybe someone using rtd without docker can test this to make sure this doesn't break that workflow.