Generate JSON during build time.
[naja.git] / setup.py
index ed17c8664a7c7a286e0f713d236170f4c8b8355b..f39ff02542efe5d89ebfbb3b2f7eccc7c9a0940e 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -5,6 +5,10 @@
 """Setuptools setup.py file for Robolock II."""
 
 from setuptools import setup, find_packages
+from setuptools.command.sdist import sdist
+from setuptools.command.install import install
+
+from tools import gen_json
 
 try:
     import py2exe
@@ -15,6 +19,19 @@ except ImportError:
 # This should probably be pulled from constants.py
 VERSION_STR = "0.1"
 
+
+class NajaSdist(sdist):
+    def run(self):
+        gen_json.main()
+        sdist.run(self)
+
+
+class NajaInstall(install):
+    def run(self):
+        gen_json.main(update=False)
+        install.run(self)
+
+
 setup(
     name="robolock-II",
     version=VERSION_STR,
@@ -65,12 +82,21 @@ setup(
         'pygame',
     ],
 
+    setup_requires=[
+        'PyYAML',
+    ],
+
     # Files
     packages=find_packages(),
     scripts=[
         'scripts/naja',
     ],
 
+    cmdclass={
+        'sdist': NajaSdist,
+        'install': NajaInstall,
+    },
+
     # py2exe
     windows=[{
         'script': 'scripts/naja',