Is is safe to use pip.__version__?

I need to check the pip version in a test. Is it safe to use python -c "import pip; print(pip.__version__)"? It’s there for the current versions from 8+, including 10.0. Would prefer not to have to run pip --version and then pick out the number. importlib-metadata is not installed in the temporary venv that I’m checking. This is for https://github.com/pypa/build/pull/229

1 Like

This is not a general Python question, is very specific to the pip. As such should be asked on the pip issue tracker rather than here. Not all pip maintainers monitor this forum.

I clicked on the issue tracker and “ask a question there” took me here. Guess I’ll open it as a blank issue.

Opened here: Is it safe to use pip.__version__? · Issue #9596 · pypa/pip · GitHub