Greetings, It was brought to my attention last week that one area where this change will visibly affect charms is with actions. Your action will need to to be run from within the venv. There is an existing activate_venv function provided by the basic layer, but with the most recent change there is an even easier way to handle it: simply change the shebang line at the top of your action file to:
#!/usr/local/sbin/charm-env python3 When your action is run, it will activate the proper venv, and it will also add $JUJU_CHARM_DIR/lib to your PYTHONPATH to make it easy to use library files included in your charm or base layers. On Thu, Mar 8, 2018 at 3:51 PM, Cory Johns <cory.jo...@canonical.com> wrote: > Greetings, > > A change to layer:basic just landed[1] that changes the default value for > the use_venv and include_system_packages layer options[2] to be enabled by > default. > > This change will prevent a confusing bug that people run into when dealing > with subordinates or co-located charms on a single machine: if co-located > charms have different versions of some of their dependencies, especially > charms.reactive or charmhelpers, they would conflict and sometimes cause > one of the charms to break. This fixes the issue by isolating the charm's > Python dependencies in a virtual environment. The change to > include_system_packages is to ensure that charms that rely on Python > libraries installed via apt will still function. > > In general, this should be transparent to almost every charm. The only > real concern is if the charm relies on command-line tools provided by any > of the Python packages; with the packages now in the venv, the venv will > need to be activated before the CLI tools can be used. The PR does provide > shims for the charms.reactive CLI and charmhelpers CLI (chlp), as well as > the layer_option CLI provided by the basic layer itself. These can be > accessed globally and will use Juju context information to activate the > correct virtual environment. > > On the off chance that you do run into an issue with this change, it's > easy to disable it for your charm. Just add the following to your > layer.yaml: > > options: > basic: > use_venv: false > > > [1]: https://github.com/juju-solutions/layer-basic/pull/105 > [2]: https://charmsreactive.readthedocs.io/en/latest/ > layer-basic.html#layer-configuration >
-- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju