4
from subprocess import check_call
7
def bootstrap_charm_deps():
8
if os.path.exists('wheelhouse/.bootstrapped'):
10
# bootstrap wheelhouse
11
if os.path.exists('wheelhouse'):
12
apt_install(['python3-pip', 'python3-yaml'])
13
# install packages defined in layer.yaml
15
# need newer pip, to fix spurious Double Requirement error https://github.com/pypa/pip/issues/56
16
check_call(['pip3', 'install', '-U', '--no-index', '-f', 'wheelhouse', 'pip'])
17
# install the rest of the wheelhouse deps
18
check_call(['pip3', 'install', '-U', '--no-index', '-f', 'wheelhouse'] + glob('wheelhouse/*'))
19
# flag us as having already bootstrapped so we don't do it again
20
open('wheelhouse/.bootstrapped', 'w').close()
21
# Ensure that the newly bootstrapped libs are available.
22
# Note: this only seems to be an issue with namespace packages.
23
# Non-namespace-package libs (e.g., charmhelpers) are available
24
# without having to reload the interpreter. :/
25
os.execl(sys.argv[0], sys.argv[0])
28
def install_charm_deps():
29
from charms import layer
31
cfg = layer.options('basic')
32
apt_install(cfg.get('packages', []))
35
def apt_install(packages):
36
if isinstance(packages, (str, bytes)):
39
env = os.environ.copy()
41
if 'DEBIAN_FRONTEND' not in env:
42
env['DEBIAN_FRONTEND'] = 'noninteractive'
45
'--option=Dpkg::Options::=--force-confold',
48
check_call(cmd + packages, env=env)