From 5bed90a42bfd099b33a1fecdd5ff676176f2c8e9 Mon Sep 17 00:00:00 2001 From: Filippo Valle Date: Mon, 5 Sep 2022 13:41:51 +0200 Subject: [PATCH] Handle M1 chips --- cpu_cores/darwin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpu_cores/darwin.py b/cpu_cores/darwin.py index 154e1b5..af6799e 100644 --- a/cpu_cores/darwin.py +++ b/cpu_cores/darwin.py @@ -27,9 +27,12 @@ def _count(self, command=None): for line in lines: tmp = line.strip() if tmp.startswith(b'Total Number of Cores:'): - self._physical_cores_count = int(tmp.split(b':')[1]) + self._physical_cores_count = int(tmp.split(b':')[1].decode('utf-8').split('(')[0].replace(' ','')) if tmp.startswith(b'Number of Processors:'): self._physical_processors_count = int(tmp.split(b':')[1]) + if tmp.startswith(b'Chip:'): + if b"Apple M" in tmp: + self._physical_processors_count = 1 if self._physical_processors_count is None or \ self._physical_cores_count is None: raise Exception('impossible to get the cpu cores count (darwin)')