The tests assumed a POSIX host, but pytest also runs on windows-latest.
Both path flavours are now built with PurePosixPath and PureWindowsPath,
which work on either host, the bin/Scripts layout is asserted against the
host, and the executable bit is only checked where it exists.
Also drops the trailing separator from PATH when PATH is unset, since an
empty entry makes Unix search the working directory for executables.
script/setup and script/setup.bat implemented the same workflow and were
kept in sync by hand, which had already drifted: the worktree hook fix in
#18843 landed in the bash script only. Both are now thin wrappers around
script/setup.py, so there is one implementation to maintain.
The post-checkout hook also checks for a venv/Scripts layout before doing
anything, so a branch switch on Windows can no longer clear a working
virtual environment.