{"id":6997,"library":"archspec","title":"Archspec","description":"Archspec is a Python library designed to provide a standard set of human-understandable labels for system architectures, primarily focusing on CPU microarchitectures. It offers APIs to detect, query, and compare different CPU types. The project originated from Spack and is under active development. The current version is 0.2.5. While it does not follow a strict release cadence, its update history, including a significant release in October 2024, indicates ongoing maintenance and development.","status":"active","version":"0.2.5","language":"en","source_language":"en","source_url":"https://github.com/archspec/archspec.git","tags":["system","architecture","cpu","microarchitecture","detection","compatibility","optimization"],"install":[{"cmd":"pip install archspec","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The `host` function is the primary way to detect the current CPU microarchitecture.","symbol":"host","correct":"from archspec.cpu.detect import host"},{"note":"Used to represent and interact with CPU microarchitecture objects.","symbol":"Microarchitecture","correct":"from archspec.cpu import Microarchitecture"}],"quickstart":{"code":"import archspec.cpu.detect\n\ntry:\n    host_cpu = archspec.cpu.detect.host()\n    if host_cpu:\n        print(f\"Detected host CPU microarchitecture: {host_cpu.name}\")\n        # Example of accessing properties\n        # print(f\"Vendor: {host_cpu.vendor}\")\n        # print(f\"Ancestors: {[a.name for a in host_cpu.ancestors]}\")\n    else:\n        print(\"Could not detect host CPU microarchitecture.\")\n        print(f\"Reason: {archspec.cpu.detect.why_not('native')}\")\nexcept archspec.cpu.UnsupportedMicroarchitecture:\n    print(\"Host microarchitecture is not recognized or supported by archspec.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart code snippet demonstrates how to detect the host CPU microarchitecture using `archspec.cpu.detect.host()` and print its name. It also includes basic error handling for unsupported architectures."},"warnings":[{"fix":"Update references to Graviton microarchitectures to use the new naming scheme (e.g., 'cortex_a72' instead of 'graviton').","message":"The naming scheme for Graviton chips changed in v0.2. Graviton is now named 'cortex_a72', Graviton2 is 'neoverse_n1', and 'neoverse_v1' was introduced instead of Graviton3.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Ensure your environment uses Python 3.6 or newer.","message":"Support for Python 2.7 and Python 3.5 was dropped in v0.2.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"For development, install Poetry (e.g., `curl -sSL https://install.python-poetry.org | python3 -`) then clone the repository and run `poetry install`. For general use, `pip install archspec` is sufficient.","message":"Installing directly from the GitHub repository for development requires Poetry.","severity":"gotcha","affected_versions":"All versions (development)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"This often occurs on newer or less common architectures. Check the `archspec.cpu.detect.why_not()` function for a more detailed reason. You might need to update Archspec to a newer version or contribute your architecture's data.","cause":"The CPU microarchitecture of the host system could not be identified by Archspec, or it is not present in its internal database.","error":"archspec.cpu.UnsupportedMicroarchitecture: Host microarchitecture is not supported."},{"fix":"Ensure that compiler versions are provided as dot-separated digits (e.g., '10.0.0' for GCC 10.0.0).","cause":"An incorrect or unparseable string was provided for a compiler version when querying optimization flags or similar features.","error":"archspec.cpu.InvalidCompilerVersion: Invalid format for compiler version."}]}