Generate settings file during build

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: If8831a33757a71bf4c544d7b1a57433361bc4fc8
diff --git a/README b/README
new file mode 100644
index 0000000..ad91674
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+To regenerate the settings file manually run:
+
+python setup.py build
diff --git a/setup.py b/setup.py
index fc23ee1..7152014 100644
--- a/setup.py
+++ b/setup.py
@@ -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})