Skip to content

Instantly share code, notes, and snippets.

@amnuts
Created December 8, 2021 10:22

Revisions

  1. amnuts created this gist Dec 8, 2021.
    13 changes: 13 additions & 0 deletions isM1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import platform
    import subprocess


    def isMac() -> bool:
    return platform.system() == 'Darwin'

    def getMacProcessor() -> str:
    return subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).decode('utf-8').rstrip()

    def isM1() -> bool:
    return getMacProcessor().lower() == 'apple m1'