-
-
Notifications
You must be signed in to change notification settings - Fork 637
Expand file tree
/
Copy pathinstall.py
More file actions
45 lines (36 loc) · 1.38 KB
/
Copy pathinstall.py
File metadata and controls
45 lines (36 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
import os
import sys
from pathlib import Path
def _pykrita_path() -> Path | None:
if sys.platform.startswith("linux"):
return Path.home() / ".local" / "share" / "krita" / "pykrita"
if sys.platform == "darwin":
return Path.home() / "Library" / "Application Support" / "Krita" / "pykrita"
if sys.platform == "win32":
appdata = os.environ.get("APPDATA")
if appdata:
return Path(appdata) / "krita" / "pykrita"
return Path.home() / "AppData" / "Roaming" / "krita" / "pykrita"
return None
def main() -> None:
pykrita = _pykrita_path()
if pykrita is None:
print("Error: Unsupported operating system:", sys.platform, file=sys.stderr)
return
if not pykrita.is_dir():
print("Error: Krita pykrita folder does not exist:", pykrita, file=sys.stderr)
return
repository = Path(__file__).resolve().parent
for name in ("ai_diffusion", "ai_diffusion.desktop"):
source = repository / name
link = pykrita / name
if not link.exists() or link.is_symlink():
link.unlink(missing_ok=True)
link.symlink_to(source, target_is_directory=source.is_dir())
print("Created symlink", link)
else:
print("Error: Existing file or folder at", link, file=sys.stderr)
return
if __name__ == "__main__":
main()