diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2016-09-21 14:50:36 -0400 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-09-28 12:39:55 +0000 |
commit | 54be910bd0af885217adc7dfcd95b7db9a13886d (patch) | |
tree | 95ff2f93d570a4d04958ed7087cf6de57b90b4f0 | |
parent | 3b3cffb64bdae4dec24134f5f5163117cdecb1f3 (diff) | |
download | phosphor-settingsd-54be910bd0af885217adc7dfcd95b7db9a13886d.tar.gz phosphor-settingsd-54be910bd0af885217adc7dfcd95b7db9a13886d.zip |
Generate settings file during build
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: If8831a33757a71bf4c544d7b1a57433361bc4fc8
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | setup.py | 20 |
2 files changed, 22 insertions, 1 deletions
@@ -0,0 +1,3 @@ +To regenerate the settings file manually run: + +python setup.py build @@ -1,7 +1,25 @@ from distutils.core import setup +from distutils.command.build import build +import yaml +import pprint + +class CustomBuild(build): + def run(self): + build.run(self) + + SETTINGS_FILE = 'settings.yaml' + OUTPUT_FILE = 'settings_file.py' + + with open(SETTINGS_FILE) as s: + data = yaml.safe_load(s) + + with open(OUTPUT_FILE, 'w') as f: + f.write('SETTINGS=\\\n') + pprint.pprint(data, stream=f) setup( name='phosphor-settings', version='1.0', scripts=['settings_manager.py'], - data_files=[('phosphor-settings', ['settings_file.py'])]) + data_files=[('phosphor-settings', ['settings_file.py'])], + cmdclass={'build': CustomBuild}) |