Browse Source

Some build infrastructure.

Douglas William Thrift 7 years ago
parent
commit
cff9beb8c5
7 changed files with 110 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 37 0
      GNUmakefile
  3. 23 0
      bincmd.py
  4. 10 0
      dthome.wsgi
  5. 26 0
      pkg.py
  6. 12 0
      touch.py
  7. 1 0
      usbuirt.py

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 *.pyc
+.requirements

+ 37 - 0
GNUmakefile

@@ -0,0 +1,37 @@
+# DT Home
+#
+# Douglas Thrift
+#
+# GNUmakefile
+
+ifeq ($(OS),Windows_NT)
+    ATTRIB := attrib
+    RM_F := del /F /A
+    TOUCH := python touch.py
+else
+    ATTRIB := true
+    RM_F := rm -f
+    TOUCH := touch
+endif
+
+pyc := $(patsubst %.py,%.pyc,$(wildcard *.py */*.py))
+
+.PHONY: all requirements clean
+
+all: dthome.wsgi
+
+dthome.wsgi: .requirements $(pyc) $(wildcard views/*.tpl)
+	$(TOUCH) $@
+
+requirements: .requirements
+
+.requirements: requirements.txt
+	python pkg.py install -r requirements.txt
+	$(TOUCH) $@
+	$(ATTRIB) +H $@
+
+%.pyc: %.py
+	python -m py_compile $<
+
+clean:
+	-$(RM_F) .requirements $(pyc)

+ 23 - 0
bincmd.py

@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# DT Home
+#  Bin Command
+#
+# Douglas Thrift
+#
+# bincmd.py
+
+import os.path
+import subprocess
+import sys
+
+_bin = os.path.join(os.path.dirname(os.path.dirname(subprocess.check_output('where git'))), 'bin')
+
+def cmd(command, args = None):
+    if args is None:
+        args = sys.argv[1:]
+
+    exe = os.path.join(_bin, "%s.exe" % command)
+
+    assert os.path.isfile(exe)
+
+    sys.exit(subprocess.call([command] + args, executable = exe))

+ 10 - 0
dthome.wsgi

@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+# DT Home
+#
+# Douglas Thrift
+#
+# dthome.wsgi
+
+import dthome
+
+application = dthome.bottle.app()

+ 26 - 0
pkg.py

@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# DT Home
+#  Package
+#
+# Douglas Thrift
+#
+# pkg.py
+
+import pip
+import platform
+
+pkg = lambda args: sys.exit(pip.main(args))
+
+# Only use PyPM on 32bit ActivePython since 64bit requires a Business License
+if platform.system() == 'Windows' and platform.machine() == 'x86':
+    try:
+        import pypm
+
+        pkg = lambda args: pypm.cmd(['-g'] + args)
+    except ImportError:
+        pass
+
+if __name__ == '__main__':
+    import sys
+
+    pkg(sys.argv[1:])

+ 12 - 0
touch.py

@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# DT Home
+#  Touch
+#
+# Douglas Thrift
+#
+# touch.py
+
+import bincmd
+
+if __name__ == '__main__':
+    bincmd.cmd('touch')

+ 1 - 0
usbuirt.py

@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 # DT Home
 #  USB UIRT
 #