git clean can't deal with junctions and in case there is a loop
it follows them forever (or until stack overflow).
https://github.com/git-for-windows/git/issues/5320
To work around this try to delete all junctions in the clean
re-try code path.
Fixes#108
As found out here, os.walk() by default follows junctions, which we don't
want and can even lead to loops:
https://github.com/msys2/msys2-autobuild/issues/101#issuecomment-2583121845
Integrate the workaround mentioned in the CPython bug report:
https://github.com/python/cpython/issues/67596#issuecomment-1918112817
Since this is Python 3.12+ only and we still support 3.10 make
it optional though.
This also adds tests, which uncovered some other minor issues:
It was not chmoding top-down, which meant that os.walk would
skip things if there were no read permissions. So chmod before
os.walk() lists the dir.
We only looked at the dependencies of a package that are needed for building,
but for detecting build cycles we also have to look at all transitive deps.
Unless the dependency is already finished, then we can ignore its build deps,
even if they are not finished yet.
The test shows such a case where things indirectly create a cycle via cmake.
Fixes#91