summaryrefslogtreecommitdiff
path: root/tools/read-dependencies
blob: fee3efcf8d66062006d3261b61c341d2fca616d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

import os
import sys

if 'CLOUD_INIT_TOP_D' in os.environ:
    topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
else:
    topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

for fname in ("setup.py", "requirements.txt"):
    if not os.path.isfile(os.path.join(topd, fname)):
        sys.stderr.write("Unable to locate '%s' file that should "
                         "exist in cloud-init root directory." % fname)
        sys.exit(1)

with open(os.path.join(topd, "requirements.txt"), "r") as fp:
    for line in fp:
        if not line.strip() or line.startswith("#"):
            continue
        sys.stdout.write(line)

sys.exit(0)