Open anatol opened 2 months ago
I was unable to find evidence that tests run codespell
from $PATH
in the logs you're provide, but you're probably right:
https://github.com/codespell-project/codespell/blob/8097264ed0fd207777c001dcf544beec14e36155/codespell_lib/tests/test_basic.py#L66-L73
Perhaps we expect codespell to be installed in dev mode before running the tests.
Perhaps we expect codespell to be installed in dev mode before running the tests.
This won't work in all cases. e.g. many Linux distros use a clean build environment with precise set of dependencies. codespell
cannot be installed there as otherwise it will be a chicken-egg problem.
Instead expecting codespell
installed, the tests should use path to newly built binary, or add that directory to $PATH
.
It makes sense. However, the Development setup does not provide a "newly built binary", apart from the installed one. How to combine both?
See also #2595.
@anatol What do you mean exactly by "newly built binary"? Note that the codespell
script is created by setuptools:
https://github.com/codespell-project/codespell/blob/523b9c57b58a9a857e9e1dc44dabe3455cc4867d/pyproject.toml#L60-L61
I understand that setuptools creates the script while installing. If so, it makes sense to install (perhaps in a temporary location) before testing.
On my workstation, the generated codespell
scripts looks like this:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from codespell_lib import _script_main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(_script_main())
We could of course create and run something similar in our tests instead of running codespell
. But what's wrong with testing the generated script (even within a temporary location) instead of testing our idea of what the generated script looks like?
Right now, we haven't heard from Linux manitainers, and therefore haven't got actual feedback about the chicken-egg problem, or how to circumvent it.
It looks like the project tests use
codespell
from$PATH
rather than from the source tree.I am following Arch linux build instructions. I build the project with
python -m build --wheel --no-isolation
then run tests withpytest
and it fails: