{"id":576,"library":"ruamel-yaml-clib","title":"ruamel-yaml-clib","description":"ruamel-yaml-clib is a C-based reader, parser, and emitter for the ruamel.yaml library, derived from libyaml. It enhances the performance of ruamel.yaml by providing C extensions for core YAML processing operations. This package was split from ruamel.yaml to facilitate the creation of universal wheels and streamline platform-specific compilation. The current version is 0.2.15.","status":"active","version":"0.2.15","language":"python","source_language":"en","source_url":"https://sourceforge.net/projects/ruamel-yaml-clib/","tags":["yaml","parser","c-library","config","libyaml","performance"],"install":[{"cmd":"pip install ruamel-yaml-clib","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"ruamel-yaml-clib is a backend for ruamel.yaml and is not imported directly by user code. ruamel.yaml detects and utilizes ruamel-yaml-clib automatically if installed, unless pure Python parsing is explicitly requested (e.g., YAML(pure=True)).","symbol":"YAML","correct":"from ruamel.yaml import YAML"}],"quickstart":{"code":"import sys\nfrom ruamel.yaml import YAML\n\n# ruamel.yaml will automatically use ruamel-yaml-clib if available\n# For pure Python implementation, use: yaml = YAML(pure=True)\nyaml = YAML()\n\ndata = {\n    'name': 'Alice',\n    'age': 30,\n    'details': {\n        'city': 'New York',\n        'occupation': 'Engineer'\n    }\n}\n\n# Dump to string\nimport io\nstring_stream = io.StringIO()\nyaml.dump(data, string_stream)\nyaml_string = string_stream.getvalue()\nprint('--- Dumped YAML ---')\nprint(yaml_string)\n\n# Load from string\nloaded_data = yaml.load(yaml_string)\nprint('--- Loaded Data ---')\nprint(loaded_data['name'])\nprint(loaded_data['details']['city'])\n\n# Demonstrate round-trip preservation (if ruamel.yaml is configured for it)\nconfig_yaml_str = \"\"\"\n# My config\nkey: value # inline comment\nlist:\n  - item1\n  - item2\n\"\"\"\n\nrt_yaml = YAML()\nrt_data = rt_yaml.load(config_yaml_str)\nrt_data['list'].append('item3')\n\noutput_stream = io.StringIO()\nrt_yaml.dump(rt_data, output_stream)\nprint('--- Round-trip preserved ---')\nprint(output_stream.getvalue())","lang":"python","description":"This quickstart demonstrates basic loading and dumping of YAML using `ruamel.yaml`. If `ruamel-yaml-clib` is installed, `ruamel.yaml` will use its C extensions for improved performance without requiring any changes to user code. To explicitly use the pure Python implementation, instantiate `YAML(pure=True)`."},"warnings":[{"fix":"Install `ruamel.yaml` with the `libyaml` extra: `pip install ruamel.yaml[libyaml]`. If `ruamel-yaml-clib` is installed directly, `ruamel.yaml` will still detect and use it.","message":"Starting with `ruamel.yaml` version 0.19.1, the library no longer automatically installs `ruamel-yaml-clib` as a direct dependency. To ensure the C-accelerated backend is installed, users must explicitly install `ruamel.yaml` with the `libyaml` extra, e.g., `pip install ruamel.yaml[libyaml]`.","severity":"breaking","affected_versions":"ruamel.yaml >= 0.19.1"},{"fix":"Workarounds may involve patching the source code or using an older/different compiler toolchain. Refer to `ruamel.yaml.clib` issue trackers or community discussions for specific patches.","message":"Compilation issues may occur with newer `clang` versions (e.g., >= 16) when building `ruamel-yaml-clib` from source. This typically manifests in environments like FreeBSD where `clang` is the default compiler.","severity":"gotcha","affected_versions":"All versions when compiling with affected clang versions"},{"fix":"If different indentation settings for mappings and sequences are required, instantiate `ruamel.yaml.YAML(pure=True)` to force the pure Python implementation.","message":"When `ruamel-yaml-clib` is active (using the C-based SafeLoader/SafeDumper within `ruamel.yaml`), the `yaml.indent` setting applies uniformly to both mappings and sequences. The pure Python implementation of `ruamel.yaml` offers more granular control over indentation styles.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For applications requiring free-threading support with `ruamel.yaml`'s C backend in the future, monitor `ruamel.yaml`'s documentation for guidance on adopting `ruamel.yaml.clibz`.","message":"The maintainer has indicated that `ruamel.yaml.clib` will not receive fixes for free-threading issues. `ruamel.yaml.clibz` is the designated replacement for future free-threading support. While `ruamel.yaml.clib` remains functional, this signals a future transition.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Install the package using pip: `pip install ruamel.yaml`.","message":"`ruamel.yaml` is not installed. Attempting to import `ruamel.yaml` without it being present in the environment will result in a `ModuleNotFoundError`.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure `ruamel.yaml` is installed in the test environment using `pip install ruamel.yaml`. Verify installation logs for any errors if the command was executed.","message":"The `ruamel.yaml` package was not found, resulting in a `ModuleNotFoundError`. This indicates the library was not successfully installed in the environment.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T16:14:49.157Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install a C/C++ compiler toolchain (e.g., `build-essential` on Linux, Xcode Command Line Tools on macOS, Build Tools for Visual Studio on Windows) and retry `pip install ruamel-yaml-clib` or `pip install ruamel.yaml`.","cause":"The C extension for `ruamel-yaml-clib` could not be compiled, typically due to a missing C/C++ compiler or required development libraries on the system.","error":"ERROR: Failed building wheel for ruamel-yaml-clib"},{"fix":"Reinstall `ruamel-yaml-clib` and `ruamel.yaml` in a clean virtual environment: `pip uninstall ruamel-yaml-clib ruamel.yaml && pip install ruamel.yaml`. Ensure no old or conflicting versions are present.","cause":"The internal C extension module `_ruamel_yaml`, which is part of `ruamel-yaml-clib` and used by `ruamel.yaml`, failed to load at runtime, often due to a corrupted installation or incompatible environment.","error":"ImportError: cannot import name '_ruamel_yaml' from 'ruamel.yaml.ext._ruamel_yaml'"},{"fix":"Verify that `ruamel-yaml-clib` is installed and its C extensions were successfully built. If not, reinstall `ruamel-yaml-clib` (or `ruamel.yaml` which pulls it in) ensuring all necessary build tools are available on your system.","cause":"The `ruamel.yaml` library failed to load its C extension (provided by `ruamel-yaml-clib`), causing it to fall back to a slower pure Python implementation without stopping execution.","error":"UserWarning: Cannot load C-module 'ruamel_yaml.ext._ruamel_yaml'"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.2.15","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.5M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"21.4M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"23M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"13.3M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"15M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"13.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"14M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.0M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}