feat: include libyaml-dev for apt charm plug-in builds #1766
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Operator framework charms will try to use the libyaml based PyYAML, which is significantly faster than the pure Python one. In an apt system, like Ubuntu, this requires
libyaml-dev
to build from source. If the libyaml dev files are not available, then the pure Python version will be built instead.Charms can get the faster version by including
libyaml-dev
in thebuild-packages
section of the metadata, or by allowing PyYAML as a binary package (the wheel has the faster version). However, this is fairly esoteric knowledge.Since the charm plug-in is specifically for operator framework charms, and ops has PyYAML as a dependency so be required for every ops charm, it seems reasonable to have
libyaml-dev
as a build dependency, which means that everyone (on an apt-based system) will get the faster YAML processing for 'free'.Detailed timing for setting relation data can be found using the example charm in this repo. Setting 4MB of relation data with the pure Python version takes around 2s, and with the libyaml version around 0.02s. This can be significant for some charms.
A complete test for this would be to do a basic charm build and verify that the .so file is included in the
venv/yaml
folder, but I wasn't sure whether that sort of test would be appropriate for charmcraft or not. Let me know if I should work on that, assuming that you're inclined to accept this change.