Missing yaml import for charmhelpers on Xenial?

Brad Crittenden bac at canonical.com
Fri Jul 1 15:23:34 UTC 2016


> On Jul 1, 2016, at 11:15 , Pete Vander Giessen <pete.vandergiessen at canonical.com> wrote:
> 
> Hi All,
> 
> I ran into an issue making a version of the mariadb charm for Xenial, and wanted to know if others had run into it, and whether we had any best practices or workarounds.
> 
> Mariadb is a non layered charm that uses hooks written in Python. Two of the hooks -- "install' and "config-changed", specifically -- import charmhelpers. Both of those hooks fail on an import error on Xenial, when charmhelpers attempts to import yaml.
> 
> Pyaml isn't part of the Python standard library, but it looks like it is installed by default in the default Python distribution on any given series of Ubuntu. On Xenial, this means that yaml is automatically available to  Python 3, but not to Python 2, which is what the scripts were using.
> 
> The solution is either to a) port the install and config-changed hooks to python3, which is what I did while rushing to meet a deadline yesterday, or b) to install yaml in Python 2, which is the simpler solution that seems obvious this morning, after I am no longer worried about deadlines :-)  (Note that solution "a" breaks the charm in trusty, as Python 3 is not the default version of Python for Trusty, and does not have yaml installed by default in that series.)
> 
> I wanted to ping the list to see if anybody had run into similar problems porting charms to Xenial, however. Should I open a ticket against charmhelpers to add pyaml as a dependency? Are there other, better workarounds?

We have run into this problem. Our solution was to make the charms work with Python3 on trusty and xenial. The yaml issue was solved by creating a script that installs python3-yaml and other required packages before calling our python install hook. I can provide an example if you want.

—Brad





More information about the Juju mailing list