Conversation
TL;DR@danischm asked why
Note: Risk assessment: adding
|
| Platform | Before this PR | After this PR | Net change |
|---|---|---|---|
| macOS / Linux | already installed (via genie) | installed | none — now explicit and floor-pinned |
| Windows | absent (pyats/genie excluded) | installed | new, and the only new install surface |
On macOS/Linux we introduce nothing new into the user base; we make explicit what genie already forces. To be precise about what changes: nac_yaml was already C-accelerated there, since it leaves pure=False as the default and clib was already present. The real deltas in this PR are (a) nac_test.utils.yaml no longer opts out via pure=True, and (b) Windows gains acceleration.
3. Install-time risk
This is the failure mode that would actually affect users: if no wheel matches a user's platform, pip falls back to the sdist and requires a local C compiler — which would break pip install nac-test for anyone without a toolchain.
Current coverage is 46 wheels spanning cp310–cp313 (our entire supported range): macosx_universal2 / arm64, manylinux2014 (x86_64 / aarch64 / i686), musllinux_1_2, win32, win_amd64. Every platform we support has a pre-built wheel, including the Windows case that is new here.
Two items to track:
- cp314 currently has no
manylinuxwheels (only macOS, musl, Windows). If we add Python 3.14, glibc Linux would fall back to compiling from sdist. This arrives via genie regardless of this PR, but it is worth watching before we bump supported versions. - Exotic platforms outside the wheel matrix would hit the sdist path. Same caveat already applies today on macOS/Linux via genie, so this PR only extends it to Windows.
4. Version constraint check
| Package | Constraint on clib |
|---|---|
genie.libs.sdk |
ruamel.yaml.clib<0.2.15 |
nac-test (this PR) |
ruamel-yaml-clib>=0.2.12; platform_python_implementation == 'CPython' |
No conflict. The effective window on macOS/Linux is >=0.2.12,<0.2.15, resolving to 0.2.14. Genie owns the ceiling, we own the floor. One nuance: on Windows genie is absent, so no ceiling applies and Windows may resolve to a newer clib than macOS/Linux once 0.2.15 ships.
The platform_python_implementation == 'CPython' marker correctly excludes PyPy, where the C extension is neither available nor desirable.
5. Forward-looking note: clib → clibz
Flagging for a future change, not this PR. ruamel.yaml 0.19.1 declares two accelerator extras:
ruamel.yaml.clib; extra == "oldlibyaml"
ruamel.yaml.clibz>=0.3.7; extra == "libyaml"
and cyaml.py now prefers _ruamel_yaml with a fallback to _ruamel_yaml_clibz. The naming ("oldlibyaml") signals upstream is migrating toward ruamel.yaml.clibz.
We should stay on ruamel.yaml.clib for now: it is what genie pins and installs, and it is what is actually active today (cyaml.__yaml_lib == 'clib'). But when genie moves, we should follow — possibly by depending on the extra (ruamel.yaml[oldlibyaml]) rather than the package directly, so upstream chooses the accelerator for us.
One behavioural caveat worth disclosing
The C emitter produces textually different output from the pure-Python emitter: long scalars wrap differently and multi-line strings are quoted differently. Round-trip data is identical, but the bytes are not.
Blast radius is small — dump() is used only in testbed_generator.py to produce pyATS testbed YAML, which pyATS re-parses (machine-consumed, never diffed or committed). But if we ever snapshot-test emitted YAML, that would need attention.
Recommendation
Keep it as a direct dependency. It is already unconditionally installed on macOS/Linux via genie, wheels cover every supported interpreter and platform, and there is no version conflict. Making it optional would add a user-facing knob, a second CI configuration, and support ambiguity — without removing any risk that actually exists.
Description
Enables C-accelerated YAML parsing and dumping by switching
ruamel.yaml.YAML(typ="safe")frompure=Truetopure=Falseinnac_test/utils/yaml.py, and addsruamel.yaml.clibas an explicit dependency for CPython inpyproject.toml.ruamel.yaml.clibwas already installed on macOS and Linux before this PR, pulled in unconditionally bygenie → genie-libs → genie-libs-sdk. Two consequences:nac_yamlwas already C-accelerated on macOS/Linux. It leavespure=Falseat its default, so it picked upclibtransitively. This PR does not newly enable that — it guarantees and version-pins the dependency explicitly instead of relying on a transitive one.pyats/genieare excluded there (sys_platform != 'win32'), soclibwas absent. Windows now gains C-acceleration for bothnac_test.utils.yamlandnac_yaml.The measurable delta from this PR:
nac_test.utils.yamlstops opting out viapure=Trueon all platforms (~3.1× faster YAML loading), and Windows gains acceleration across the board.Closes
Related Issue(s)
Type of Change
Test Framework Affected
Network as Code (NaC) Architecture Affected
Platform Tested
Key Changes
nac_test/utils/yaml.py:YAML(typ="safe", pure=True)toYAML(typ="safe", pure=False)in_create_yaml_dumper()andsafe_load().pyproject.toml:"ruamel.yaml.clib>=0.2.12; platform_python_implementation == 'CPython'"under dependencies.uv.lock:ruamel-yaml-clibwith pre-compiled wheels for macOS, Linux, and Windows (win_amd64/win32).CHANGELOG.md:# unreleased.Testing Done
pytest/pre-commit run -a)Test Commands Used
Checklist
pre-commit run -apasses)Additional Notes
ruamel.yaml.clibdistributes pre-compiled binary wheels (.whl) on PyPI for Windows across all supported Python versions (3.10-3.14), so no local C compiler is required on Windows.YAML(typ="safe", pure=False)parses to identical Python data structures aspure=True, and raises identical exception types. Emitted YAML is semantically identical but not byte-identical — the C emitter wraps long scalars and quotes multi-line strings differently. Only affects the generated pyATS testbed file, which pyATS re-parses.