runtime-introspect


Nameruntime-introspect JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA small Python library to seamlessly introspect interpreter features at runtime
upload_time2025-08-17 16:21:39
maintainerNone
docs_urlNone
authorC.M.T. Robert
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `runtime_introspect`

[![PyPI](https://img.shields.io/pypi/v/runtime-introspect.svg?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/runtime-introspect/)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/runtime-introspect)](https://pypi.org/project/runtime-introspect/)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

A small Python library to introspect interpreter features in a couple of
portable lines of code. The core functionality is to produce diagnostics for
which optional features are (un)available, the **state** they are in (_enabled_,
_disabled_, _active_, or _inactive_), and **why**. It utilizes implementation specific
APIs to abstract away the pain of writing portable code that runs on any
configuration.


## Scope and development status

This project is currently in alpha, with a flexible scope; Only CPython
interpreter features (Free-threading and JIT) are supported at the moment.
However, the library design leaves open the possibility to add support for other
Python implementations. If you spot something missing please open a feature
request or a pull request, contributions are always welcome !


## Installation

```shell
python -m pip install runtime-introspect
```

## Usage

Here's how to produce a
```py
>>> from runtime_introspect import CPythonFeatureSet
>>> fs = CPythonFeatureSet()
>>> print("\n".join(fs.diagnostics()))
free-threading: unavailable (this interpreter was built without free-threading support)
JIT: disabled (envvar PYTHON_JIT is unset)
```


### As a `pytest` helper

You can use this library to customize `pytest` so that test session headers
showcase the runtime feature set at startup. For instance

```py
# conftest.py
import sys
from runtime_introspect import CPythonFeatureSet

# ...

def pytest_report_header(config, start_path) -> list[str]:
    if sys.implementation.name == "cpython":
        fs = CPythonFeatureSet()
        return [
            "CPython optional features state (snapshot):",
            textwrap.indent("\n".join(fs.diagnostics()), "  "),
        ]
    else:
        return []
```

example output (truncated)
```
===================================== test session starts ======================================
platform darwin -- Python 3.13.6, pytest-8.4.1, pluggy-1.6.0
CPython optional features state (snapshot):
  free-threading: unavailable (this interpreter was built without free-threading support)
  JIT: undetermined (no introspection API known for Python 3.13)
...
```


### Command Line Interface (CLI) examples

Outputs may (really, should) vary depending on which python interpreter is
active and how it was invoked

```
❯ python3.13 -m runtime_introspect
free-threading: unavailable (this interpreter was built without free-threading support)
JIT: disabled (envvar PYTHON_JIT is unset)
```
```
❯ PYTHON_JIT=1 python3.13 -m runtime_introspect
free-threading: unavailable (this interpreter was built without free-threading support)
JIT: enabled (by envvar PYTHON_JIT=1)
```
```
❯ python3.14t -X gil=0 -m runtime_introspect
free-threading: enabled (forced by command line option -Xgil=0)
JIT: unavailable (this interpreter was built without JIT compilation support)
```

Run `python -m runtime_introspect --help` to browse additional options.


## Additional resources

Many more details can be inspected with the standard library `sysconfig` CLI
(`python -m sysconfig`).

Also refer to
[`python-introspection`](https://pypi.org/project/python-introspection/) for a
similar tool with a different approach and focus.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "runtime-introspect",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "C.M.T. Robert",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2b/eb/82028553f6393bbae702098b4b12cd03b358859702bd0d306ad9edd10479/runtime_introspect-0.1.0.tar.gz",
    "platform": null,
    "description": "# `runtime_introspect`\n\n[![PyPI](https://img.shields.io/pypi/v/runtime-introspect.svg?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/runtime-introspect/)\n[![Supported Python Versions](https://img.shields.io/pypi/pyversions/runtime-introspect)](https://pypi.org/project/runtime-introspect/)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n\nA small Python library to introspect interpreter features in a couple of\nportable lines of code. The core functionality is to produce diagnostics for\nwhich optional features are (un)available, the **state** they are in (_enabled_,\n_disabled_, _active_, or _inactive_), and **why**. It utilizes implementation specific\nAPIs to abstract away the pain of writing portable code that runs on any\nconfiguration.\n\n\n## Scope and development status\n\nThis project is currently in alpha, with a flexible scope; Only CPython\ninterpreter features (Free-threading and JIT) are supported at the moment.\nHowever, the library design leaves open the possibility to add support for other\nPython implementations. If you spot something missing please open a feature\nrequest or a pull request, contributions are always welcome !\n\n\n## Installation\n\n```shell\npython -m pip install runtime-introspect\n```\n\n## Usage\n\nHere's how to produce a\n```py\n>>> from runtime_introspect import CPythonFeatureSet\n>>> fs = CPythonFeatureSet()\n>>> print(\"\\n\".join(fs.diagnostics()))\nfree-threading: unavailable (this interpreter was built without free-threading support)\nJIT: disabled (envvar PYTHON_JIT is unset)\n```\n\n\n### As a `pytest` helper\n\nYou can use this library to customize `pytest` so that test session headers\nshowcase the runtime feature set at startup. For instance\n\n```py\n# conftest.py\nimport sys\nfrom runtime_introspect import CPythonFeatureSet\n\n# ...\n\ndef pytest_report_header(config, start_path) -> list[str]:\n    if sys.implementation.name == \"cpython\":\n        fs = CPythonFeatureSet()\n        return [\n            \"CPython optional features state (snapshot):\",\n            textwrap.indent(\"\\n\".join(fs.diagnostics()), \"  \"),\n        ]\n    else:\n        return []\n```\n\nexample output (truncated)\n```\n===================================== test session starts ======================================\nplatform darwin -- Python 3.13.6, pytest-8.4.1, pluggy-1.6.0\nCPython optional features state (snapshot):\n  free-threading: unavailable (this interpreter was built without free-threading support)\n  JIT: undetermined (no introspection API known for Python 3.13)\n...\n```\n\n\n### Command Line Interface (CLI) examples\n\nOutputs may (really, should) vary depending on which python interpreter is\nactive and how it was invoked\n\n```\n\u276f python3.13 -m runtime_introspect\nfree-threading: unavailable (this interpreter was built without free-threading support)\nJIT: disabled (envvar PYTHON_JIT is unset)\n```\n```\n\u276f PYTHON_JIT=1 python3.13 -m runtime_introspect\nfree-threading: unavailable (this interpreter was built without free-threading support)\nJIT: enabled (by envvar PYTHON_JIT=1)\n```\n```\n\u276f python3.14t -X gil=0 -m runtime_introspect\nfree-threading: enabled (forced by command line option -Xgil=0)\nJIT: unavailable (this interpreter was built without JIT compilation support)\n```\n\nRun `python -m runtime_introspect --help` to browse additional options.\n\n\n## Additional resources\n\nMany more details can be inspected with the standard library `sysconfig` CLI\n(`python -m sysconfig`).\n\nAlso refer to\n[`python-introspection`](https://pypi.org/project/python-introspection/) for a\nsimilar tool with a different approach and focus.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A small Python library to seamlessly introspect interpreter features at runtime",
    "version": "0.1.0",
    "project_urls": {
        "Changelog": "https://github.com/neutrinoceros/runtime-introspect/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/neutrinoceros/runtime-introspect"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c0f295006bf215f840fdde18257113e54982d94a7491936ad10971fd2b465390",
                "md5": "2688ac659a38fb7f725b48446267e9df",
                "sha256": "24924cfd896983535c2ba002c122ed6ceed2913ee66bdfb5560bab6e1b42cd86"
            },
            "downloads": -1,
            "filename": "runtime_introspect-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2688ac659a38fb7f725b48446267e9df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 19692,
            "upload_time": "2025-08-17T16:21:38",
            "upload_time_iso_8601": "2025-08-17T16:21:38.020034Z",
            "url": "https://files.pythonhosted.org/packages/c0/f2/95006bf215f840fdde18257113e54982d94a7491936ad10971fd2b465390/runtime_introspect-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2beb82028553f6393bbae702098b4b12cd03b358859702bd0d306ad9edd10479",
                "md5": "7bc189d84aa6caa1c78fc41f883021e5",
                "sha256": "3ed4120be72272bd050e473fa8940bf55eeffbbc74f8bd68fa50545278f6e331"
            },
            "downloads": -1,
            "filename": "runtime_introspect-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7bc189d84aa6caa1c78fc41f883021e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22916,
            "upload_time": "2025-08-17T16:21:39",
            "upload_time_iso_8601": "2025-08-17T16:21:39.088582Z",
            "url": "https://files.pythonhosted.org/packages/2b/eb/82028553f6393bbae702098b4b12cd03b358859702bd0d306ad9edd10479/runtime_introspect-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-17 16:21:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neutrinoceros",
    "github_project": "runtime-introspect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "runtime-introspect"
}
        
Elapsed time: 2.21760s