Skip to main content

Call the cpuid instruction from Python.

Project description

Project generated with PyScaffold

python-cpuid

Call cpuid from Python code.

This module provides C bindings to call the cpuid instruction from Python code. Simply pass a MSR ID and the cpuid function will return the result as a tuple representing the eax, ebx, ecx and edx registers as integers.

from cpuid import cpuid

msr = 0x80000000    # example value
eax, ebx, ecx, edx = cpuid(msr)

CPU features

In addition to the raw cpuid functionality, this library provides helpers for commonly used CPUID registers.

from cpuid.features import prcessor_features, secure_encryption_info, vendor

vendor()   # returns the result of cpuid(0) as bytes, ex: b"GenuineIntel"
features = processor_features()    # A class with all the fields of cpuid(1)
secure_encryption_features = secure_encryption_info()   # AMD secure encryption features

Feel free to add more CPUID registers! You can find the specification in official Intel and AMD docs like this one: https://www.amd.com/system/files/TechDocs/24594.pdf.

Why?

Other projects already provide this functionality. To the best of our knowledge:

  • PyCPUID <https://github.com/ngnpope/pycpuid>_ is not compatible with Python 3. An open PR from 2015 proposes an upgrade.

  • cpuid.py looks fun, but ultimately is machine code injection. We wanted something more auditable.

Notes

We do not (yet) provide binary wheel distributions for this package, because of the added complexity of shipping compiled libraries for Linux. You will require GCC to compile the package for your system.

This project has been set up using PyScaffold 4.3. For details and usage information on PyScaffold see https://pyscaffold.org/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_cpuid-0.1.1.tar.gz (21.3 kB view details)

Uploaded Source

File details

Details for the file python_cpuid-0.1.1.tar.gz.

File metadata

  • Download URL: python_cpuid-0.1.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for python_cpuid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 092adf0d567a2ce068f10ff5b0b085b1be23cfa4ac5ac6890bc96b4f1539abbf
MD5 790cd04a99405dced468a8f66df9b8df
BLAKE2b-256 237db96d5dd57557839fc54319d4e0cfdb508bafd7ac6702c60749df196a07ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page