Commit 74911e80ce244e46f61a48d824a59aaf1b1ad24d
1 parent
653292a1
Exists in
master
and in
39 other branches
Install pkg_resource before using it
Showing
1 changed file
with
8 additions
and
4 deletions
Show diff stats
puppet/bootstrap.py
... | ... | @@ -8,9 +8,16 @@ import subprocess |
8 | 8 | import urllib |
9 | 9 | |
10 | 10 | from distutils.version import StrictVersion |
11 | -from pkg_resources import parse_requirements | |
12 | 11 | from shutil import copyfile |
13 | 12 | |
13 | +try: | |
14 | + from pkg_resources import parse_requirements | |
15 | +except ImportError: | |
16 | + # Needed dependency for import pkg_resources | |
17 | + pkg_res = ['apt-get', 'install', 'python-pkg-resources', '-y'] | |
18 | + subprocess.call(pkg_res) | |
19 | + from pkg_resources import parse_requirements | |
20 | + | |
14 | 21 | PUPPET_TARGET_VERSION = "3.6.2" |
15 | 22 | PUPPET_DIR = os.path.join(os.path.dirname(__file__)) |
16 | 23 | MODULES_FILE_PATH = os.path.join(PUPPET_DIR, 'modules.txt') |
... | ... | @@ -129,9 +136,6 @@ def main(): |
129 | 136 | update = ['apt-get', 'update', '-y'] |
130 | 137 | install = ['apt-get', 'install', 'puppet', '-y'] |
131 | 138 | |
132 | - # Needed dependency for import pkg_resources | |
133 | - pkg_res = ['apt-get', 'install', 'python-pkg-resources', '-y'] | |
134 | - subprocess.call(pkg_res) | |
135 | 139 | else: |
136 | 140 | print('This distribuition is currently not supported!') |
137 | 141 | print('exiting...') | ... | ... |