Update: makefiles, sphinx docs, tests
authorOleg Broytman <phd@phdru.name>
Sat, 16 Jul 2016 23:28:27 +0000 (02:28 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 16 Jul 2016 23:28:27 +0000 (02:28 +0300)
14 files changed:
project_template/MANIFEST.in
project_template/Makefile [new file with mode: 0644]
project_template/docs/.gitignore [new file with mode: 0644]
project_template/docs/genapidocs [new file with mode: 0755]
project_template/mk-distr
project_template/publish-docs [new file with mode: 0755]
project_template/requirements.txt
project_template/setup.cfg
project_template/setup.py
project_template/tests/Makefile [new file with mode: 0644]
project_template/tests/__init__.py [new file with mode: 0644]
project_template/tests/run_all.py [new file with mode: 0755]
project_template/tests/test_test.py [new file with mode: 0755]
project_template/update [new file with mode: 0755]

index bf0c60b..5014cb5 100644 (file)
@@ -1,2 +1,4 @@
-include COPYING ChangeLog MANIFEST.in README.txt TODO mk-distr requirements.txt
-recursive-include project *.py
+include docs/genapidocs
+include COPYING ChangeLog MANIFEST.in Makefile TODO mk-distr *.txt
+recursive-include docs Makefile *.py *.rst *.txt *.css *.js *.html *.gif *.png
+recursive-include tests Makefile *.py
diff --git a/project_template/Makefile b/project_template/Makefile
new file mode 100644 (file)
index 0000000..fc9c35e
--- /dev/null
@@ -0,0 +1,30 @@
+
+.PHONY: all
+all:
+       @echo "Nothing to be done for 'all'"
+
+.PHONY: release
+release: tests flake8 html distr
+
+.PHONY: distr
+distr:
+       ./mk-distr
+
+.PHONY: flake8
+flake8:
+       flake8
+
+.PHONY: html
+html:
+       $(MAKE) -C docs html
+
+.PHONY: test
+test:
+       $(MAKE) -C tests
+
+.PHONY: tests
+tests: test
+
+.PHONY: clean
+clean:
+       find . -name '*.py[co]' -type f -delete
diff --git a/project_template/docs/.gitignore b/project_template/docs/.gitignore
new file mode 100644 (file)
index 0000000..2be7eb5
--- /dev/null
@@ -0,0 +1,4 @@
+/_build/
+/_static/
+/_templates/
+/api/
diff --git a/project_template/docs/genapidocs b/project_template/docs/genapidocs
new file mode 100755 (executable)
index 0000000..533956b
--- /dev/null
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+cd "`dirname $0`"/.. &&
+exec sphinx-apidoc -Me -o docs/api project
index 8576eac..6c946f6 100755 (executable)
@@ -5,6 +5,10 @@ umask 022 &&
 git archive --format=tar --prefix=project/ "${1:-HEAD}" |
    (cd "$HOME/tmp" && exec tar xf -) &&
 
+cp -ap docs "$HOME/tmp/project" &&
+
 cd "$HOME/tmp/project" &&
+chmod -R u=rwX,go=rX docs &&
+
 python setup.py sdist --formats=bztar &&
 cd dist && mv project-*.tar.bz2 ../.. && cd ../.. && exec rm -rf project
diff --git a/project_template/publish-docs b/project_template/publish-docs
new file mode 100755 (executable)
index 0000000..6e52773
--- /dev/null
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+web="$HOME"/Internet/WWW/htdocs/phdru.name/Software/Python/project/docs
+
+cd "`dirname \"$0\"`"/docs/_build/html &&
+rsync -ahP --del * --exclude=objects.inv "$web" &&
+
+exec chmod -R u=rwX,go=rX "$web"
index e69de29..beed055 100644 (file)
@@ -0,0 +1,4 @@
+--trusted-host phdru.name
+--find-links=http://phdru.name/Software/Python/
+--install-option="--compile"
+
index bc17240..1872c40 100644 (file)
@@ -2,6 +2,14 @@
 universal = 1
 
 [easy_install]
+find_links = http://phdru.name/Software/Python/
+optimize = 2
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
 
 [flake8]
-exclude = .git
+exclude = .git,docs/conf.py
+
index 3c7dc16..ba44c74 100755 (executable)
@@ -16,8 +16,8 @@ except ImportError:
     is_setuptools = False
 
 versionpath = join(abspath(dirname(__file__)), 'project', '__version__.py')
-load_source('m_librarian_version', versionpath)
-from m_librarian_version import __version__
+load_source('project_version', versionpath)
+from project_version import __version__
 
 setup(name='Template project',
       version=__version__,
diff --git a/project_template/tests/Makefile b/project_template/tests/Makefile
new file mode 100644 (file)
index 0000000..b990065
--- /dev/null
@@ -0,0 +1,4 @@
+
+.PHONY: all
+all:
+       ./run_all.py
diff --git a/project_template/tests/__init__.py b/project_template/tests/__init__.py
new file mode 100644 (file)
index 0000000..3c09ede
--- /dev/null
@@ -0,0 +1,22 @@
+
+import unittest
+
+__all__ = ['TestCase', 'main']
+
+
+class TestCase(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+def main():
+    try:
+        unittest.main(testRunner=unittest.TextTestRunner())
+    except SystemExit, msg:
+        result = msg.args[0]
+    else:
+        result = 0
+    raise SystemExit(result)
diff --git a/project_template/tests/run_all.py b/project_template/tests/run_all.py
new file mode 100755 (executable)
index 0000000..2e217bf
--- /dev/null
@@ -0,0 +1,38 @@
+#! /usr/bin/env python
+
+
+import os
+import sys
+import subprocess
+
+
+def isexecutable(filename):
+    infile = open(filename, 'r')
+    magic = infile.read(2)
+    infile.close()
+    return magic == "#!"
+
+
+def collect_tests():
+    tests = []
+    for dirpath, dirs, files in os.walk("tests"):
+        tests.extend(
+            [os.path.join(dirpath, filename) for filename in files
+             if filename.startswith("test") and filename.endswith(".py")
+             ])
+    return [test[:-3].replace(os.sep, '.') for test in tests
+            if isexecutable(test)]
+
+
+def main():
+    os.chdir(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
+    tests = collect_tests()
+
+    os.environ["PYTHONPATH"] = os.curdir
+
+    for test in sorted(tests):
+        print test
+        subprocess.call((sys.executable, '-m', test))
+
+if __name__ == '__main__':
+    main()
diff --git a/project_template/tests/test_test.py b/project_template/tests/test_test.py
new file mode 100755 (executable)
index 0000000..422d67d
--- /dev/null
@@ -0,0 +1,14 @@
+#! /usr/bin/env python
+
+
+import unittest
+from tests import main
+
+
+class TestFormat(unittest.TestCase):
+    def test_test(self):
+        self.assertEqual()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/project_template/update b/project_template/update
new file mode 100755 (executable)
index 0000000..690ecaa
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+exec "$HOME"/admin/prog/git-scripts/update