Merge lp:~fginther/charm-helpers/install-python3-jinja2 into lp:charm-helpers

Proposed by Francis Ginther
Status: Merged
Merged at revision: 609
Proposed branch: lp:~fginther/charm-helpers/install-python3-jinja2
Merge into: lp:charm-helpers
Diff against target: 35 lines (+8/-3)
1 file modified
charmhelpers/core/templating.py (+8/-3)
To merge this branch: bzr merge lp:~fginther/charm-helpers/install-python3-jinja2
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+300121@code.launchpad.net

Commit message

Install python3-jinja2 when installing jinja2 under python3.

Description of the change

Install python3-jinja2 when installing jinja2 under python3.

Testing:
  Applied this patch to lp:~stub/charms/trusty/nrpe/py3 and verified that python3-jinja2 was installed. Hacked same branch to use python2 and verified that python-jinja2 was installed instead.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/templating.py'
2--- charmhelpers/core/templating.py 2016-07-06 14:41:05 +0000
3+++ charmhelpers/core/templating.py 2016-07-14 19:29:37 +0000
4@@ -13,6 +13,7 @@
5 # limitations under the License.
6
7 import os
8+import sys
9
10 from charmhelpers.core import host
11 from charmhelpers.core import hookenv
12@@ -38,8 +39,9 @@
13 The rendered template will be written to the file as well as being returned
14 as a string.
15
16- Note: Using this requires python-jinja2; if it is not installed, calling
17- this will attempt to use charmhelpers.fetch.apt_install to install it.
18+ Note: Using this requires python-jinja2 or python3-jinja2; if it is not
19+ installed, calling this will attempt to use charmhelpers.fetch.apt_install
20+ to install it.
21 """
22 try:
23 from jinja2 import FileSystemLoader, Environment, exceptions
24@@ -51,7 +53,10 @@
25 'charmhelpers.fetch to install it',
26 level=hookenv.ERROR)
27 raise
28- apt_install('python-jinja2', fatal=True)
29+ if sys.version_info.major == 2:
30+ apt_install('python-jinja2', fatal=True)
31+ else:
32+ apt_install('python3-jinja2', fatal=True)
33 from jinja2 import FileSystemLoader, Environment, exceptions
34
35 if template_loader:

Subscribers

People subscribed via source and target branches