Fixes for the following issues on windows - https://bugs.python.org/issue8557 - windows does not parse shebangs This function also makes deep-path shebangs work just fine
(
cmd: tuple[str, ...],
*,
env: Mapping[str, str] | None = None,
)
| 63 | |
| 64 | |
| 65 | def normalize_cmd( |
| 66 | cmd: tuple[str, ...], |
| 67 | *, |
| 68 | env: Mapping[str, str] | None = None, |
| 69 | ) -> tuple[str, ...]: |
| 70 | """Fixes for the following issues on windows |
| 71 | - https://bugs.python.org/issue8557 |
| 72 | - windows does not parse shebangs |
| 73 | |
| 74 | This function also makes deep-path shebangs work just fine |
| 75 | """ |
| 76 | # Use PATH to determine the executable |
| 77 | exe = normexe(cmd[0], env=env) |
| 78 | |
| 79 | # Figure out the shebang from the resulting command |
| 80 | cmd = parse_filename(exe) + (exe,) + cmd[1:] |
| 81 | |
| 82 | # This could have given us back another bare executable |
| 83 | exe = normexe(cmd[0], env=env) |
| 84 | |
| 85 | return (exe,) + cmd[1:] |
no test coverage detected