I am in the middle of debugging a problem with my CI.
I wonder how “coverage” (ping @nedbat) do determine which python interpreter binary it uses. I couldn’t find that info in the docs or in the debug output.
I am in the middle of debugging a problem with my CI.
I wonder how “coverage” (ping @nedbat) do determine which python interpreter binary it uses. I couldn’t find that info in the docs or in the debug output.
I’ve never given it much thought, but I suspect it uses the Python executable running pip when you installed it.
It will depend on how you installed coverage.
Did you use a OS package manager? Did you use pip?
You can look at the shebang line in the coverage file and check what it uses.
If on fedora I install python3-coverage
I see that the shebang line is:
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'coverage==7.2.7','console_scripts','coverage-3.12'
import re
The other way to be sure which python version is being used to to run coverage via -m
which will also when from a venv.
$ python3.12 -m coverage
Code coverage for Python, version 7.2.7 with C extension. Use 'coverage help' for help.
Full documentation is at https://coverage.readthedocs.io/en/7.2.7
The two previous replies are spot on.
The coverage debug output will show it, though there are lots of different kinds of coverage debug output. The executable
line shows which Python interpreter is being used:
% coverage debug sys
-- sys -------------------------------------------------------
coverage_version: 7.4.1
coverage_module: /usr/local/virtualenvs/tmp-6ac9a881e8c3ac0/lib/python3.11/site-packages/coverage/__init__.py
core: -none-
CTracer: available
plugins.file_tracers: -none-
plugins.configurers: -none-
plugins.context_switchers: -none-
configs_attempted: .coveragerc
setup.cfg
tox.ini
pyproject.toml
configs_read: -none-
config_file: None
config_contents: -none-
data_file: -none-
python: 3.11.7 (main, Jan 20 2024, 07:01:12) [Clang 15.0.0 (clang-1500.1.0.2.5)]
platform: macOS-14.2.1-arm64-arm-64bit
implementation: CPython
executable: /usr/local/virtualenvs/tmp-6ac9a881e8c3ac0/bin/python
def_encoding: utf-8
fs_encoding: utf-8
pid: 99930
cwd: /usr/local/virtualenvs/tmp-6ac9a881e8c3ac0
path: /usr/local/virtualenvs/tmp-6ac9a881e8c3ac0/bin
/usr/local/pyenv/pyenv/versions/3.11.7/lib/python311.zip
/usr/local/pyenv/pyenv/versions/3.11.7/lib/python3.11
/usr/local/pyenv/pyenv/versions/3.11.7/lib/python3.11/lib-dynload
/usr/local/virtualenvs/tmp-6ac9a881e8c3ac0/lib/python3.11/site-packages
environment: HOME = /Users/ned
PYTHONPYCACHEPREFIX = /tmp/ned-pyc
PYTHONSTARTUP = /Users/ned/.config/startup.py
VIRTUALENVWRAPPER_PYTHON = /usr/local/pyenv/pyenv/versions/3.11.7/bin/python3.11
command_line: /usr/local/virtualenvs/tmp-6ac9a881e8c3ac0/bin/coverage debug sys
(etc...)