scikit-build/scikit-build-core

Tests hardcode the use of pip for downloading a lot of dependencies

dvzrv opened this issue · 1 comments

Hi! 👋

We're currently rebuilding everything against Python 3.12 on Arch Linux.
This project has been pulled in as a new dependency by another one.

While trying to run tests I noticed, that it is impossible for me, because the tests require the download of other things using pip.

@pytest.fixture(scope="session")
def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
wheelhouse = tmp_path_factory.mktemp("wheelhouse")
subprocess.run(
[
sys.executable,
"-m",
"pip",
"wheel",
"--wheel-dir",
str(wheelhouse),
f"{BASE}",
],
check=True,
)
packages = [
"build",
"cython",
"hatchling",
"pip>=23",
"pybind11",
"setuptools",
"virtualenv",
"wheel",
]
if importlib.util.find_spec("cmake") is not None:
packages.append("cmake")
if importlib.util.find_spec("ninja") is not None:
packages.append("ninja")
subprocess.run(
[
sys.executable,
"-m",
"pip",
"download",
"-q",
"-d",
str(wheelhouse),
*packages,
],
check=True,
)
return wheelhouse

Please note, that this is an anti-pattern (usually your project management software e.g. poetry, pdm, flit, etc. make sure that you can test against a venv with whatever version you require). The test environment should not be downloading anything during test time (unless you are integration testing against e.g. an API).
For downstreams this makes it impossible to use the test suite of this project and that way we can not ensure that this project actually works with the rest of the ecosystem we are packaging.

Please restructure the tests in such a way, that downstreams are enabled to test against their environment with them 🙇

The pep518 tests are specifically testing the ability to do isolated builds, which downloads packages from PyPI. You can disable them with -m “not network”. There are matching pep517 tests that use the current environment and those will still run.

(I think it’s not network, IIRC not isolated works too)

I'd not be averse to a way to allow someone to pre-download them, not sure how that should be done though.