Run the Python suite and the docs build without installing anything
When to use#
Use this when you changed C++ that the Python extension builds, or Python code, and must run tests/python or the Sphinx docs, but the active environment has no editable install and you must not install tools (no pip install, no brew, no npm -g).
Steps#
Build the tests preset, which also builds the extension:
cmake --build --preset tests.Make a scratch package from the source tree and the built extension.
$SCRATCHis any scratch folder:&&Copy again after every edit to
python/or rebuild of the extension; the copy does not follow the tree.Run the suite in a throwaway
uvenvironment. SetDFTRACER_PLUGIN_INCLUDE, because the scratch package has noinclude/folder for the plugin build tests:DFTRACER_PLUGIN_INCLUDE=/include PYTHONPATH=/pypkg \Without
--with dask --with distributed, the distributed tests are skipped.The tests build is instrumented for coverage, so the run ends with many
profiling: ... .gcda: cannot merge previous GCDA filelines that push the pytest summary out oftail. Append2>&1 | grep -v '^profiling:' | tail -3to see the summary.Build the docs the same way:
PYTHONPATH=/pypkgUse
-j 1: on macOS-j autodies withobjc ... fork() was calledandEOFError. Compare the warnings with a run before your change: theautodoc: failed to import 'dfanalyzer...'warnings were already there.Run the linters with
uvx ruff check python/ tests/python/,uvx ruff format --check python/ tests/python/anduvx ty check python/.
Evidence#
- Plain
python3 -m pytest tests/python(system Python, no install) stops at collection:ModuleNotFoundError: No module named 'dftracer'.pythonis not on PATH. - Without
DFTRACER_PLUGIN_INCLUDE:PluginBuildError: cannot locate the plugin include dir; set DFTRACER_PLUGIN_INCLUDEintests/python/test_op_run.py. - Plain
sphinx-buildexited 127 (command not found); theuv run --with-requirements docs/requirements.txtform built with rc 0 and 16 warnings, all fromdfanalyzerautodoc imports. - Suite results on macOS with Python 3.14: 1102 passed, 52 skipped without dask; 1131 passed, 23 skipped with dask and distributed.
sphinx-build -j autoon macOS with Python 3.14 crashed:+[NSNumber initialize] may have been in progress in another thread when fork() was called, thenEOFErrorinmultiprocessing/connection.py;-j 1built with rc 0.DataFrame.to_dict()without pyarrow:ImportError: pyarrow is required for Arrow conversion; keep--with pyarrow.- With
uvxinstead ofuv run, name the package:uvx --from sphinx sphinx-build ...; bareuvx sphinx-buildfails withsphinx-build was not found in the package registry. - A symlinked scratch package (
ln -sfof each file inpython/dftracer/utils/and of the built.so) follows edits and rebuilds, so the copy step is not needed each time. 1159 passed, 51 skipped on 2026-09-29.
Also found by searching
- pytest tests/python -> ModuleNotFoundError: No module named 'dftracer.utils' and no editable install allowed
- I need to run the Python tests and Sphinx docs after a C++ change but I am not allowed to pip install anything
- how do I run dftracer-utils Python tests with the freshly built extension without installing the package?
- uv run --no-project --with pytest PYTHONPATH scratch package, gcda cannot merge previous GCDA file noise
- ModuleNotFoundError: No module named 'dftracer.utils' when running tests/python without editable install
- how do I run pytest and sphinx docs build against the freshly built C++ extension without pip install?
- can't pip install or brew on this machine, how do I test python bindings after cmake --build --preset tests
- make a scratch package with built .so to run tests/python and docs