summaryrefslogtreecommitdiff
path: root/tools/get_platform.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/get_platform.py')
-rw-r--r--tools/get_platform.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/get_platform.py b/tools/get_platform.py
new file mode 100644
index 00000000..a4fe40d8
--- /dev/null
+++ b/tools/get_platform.py
@@ -0,0 +1,31 @@
+import platform
+
+
+class Platform:
+ def __init__(self, *, system: str, machine: str, exe: str):
+ self.system = system
+ '''Name of operating system: "windows" or "linux"'''
+ self.machine = machine
+ '''Name of machine architecture: "x86_64"'''
+ self.exe = exe
+ '''Executable file extension: ".exe" for Windows, "" otherwise'''
+
+
+def get_platform() -> Platform | None:
+ exe = ""
+ system = platform.system()
+ if system == "Windows":
+ system = "windows"
+ exe = ".exe"
+ elif system == "Linux":
+ system = "linux"
+ else:
+ print(f"Unknown system '{system}'")
+ return None
+ match platform.machine().lower():
+ case "amd64" | "x86_64": machine = "x86_64"
+ case machine:
+ print(f"Unknown machine: {machine}")
+ return None
+
+ return Platform(system=system, machine=machine, exe=exe)