Skip to content

windows

Attributes

is_windows = any(platform.win32_ver()) module-attribute

Functions

fix_windows_longpath(path: Path) -> Path

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/kiara/utils/windows.py
12
13
14
15
16
17
18
19
def fix_windows_longpath(path: Path) -> Path:
    if not is_windows:
        return path

    normalized = os.fspath(path.resolve())
    if not normalized.startswith("\\\\?\\"):
        normalized = "\\\\?\\" + normalized
    return Path(normalized)
Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/kiara/utils/windows.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def fix_windows_symlink(source: Path, target: Path) -> None:

    if not is_windows:
        target.symlink_to(source)
        return
    else:
        try:
            target.symlink_to(source)
        except OSError:
            import traceback

            raise Exception(
                "Operating system does not support symbolic links.",
                "link",
                (source, target),
                traceback.format_exc(),
            )
Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/kiara/utils/windows.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@lru_cache
def check_symlink_works() -> bool:

    dirname = tempfile.mkdtemp()

    source = Path(dirname) / "source"
    target = Path(dirname) / "target"

    source.touch()
    try:
        target.symlink_to(source)
        return True
    except OSError:
        return False
    finally:
        shutil.rmtree(dirname, ignore_errors=True)