Commits

Gora Khargosh committed c87e933

Updates build files.

Signed-off-by: Gora Khargosh <gora.khargosh@gmail.com>

  • Participants
  • Parent commits f5f9176

Comments (0)

Files changed (4)

+RM = rm -rf
+
+PKG_NAME=mom
+
+.PHONY: all clean distclean develop lint test upload-doc view-doc doc docs build dist release auto submodules
+
+all: build
+
+help:
+	@echo "Possible targets:"
+	@echo "	   test        - run testsuite"
+	@echo "    doc(s)      - builds the documentation"
+	@echo "	   view-doc    - opens documentation in the browser"
+	@echo "	   upload-doc  - uploads the documentation to PyPI"
+	@echo "	   develop	   - set up development environment"
+	@echo "	   clean       - clean up generated files"
+	@echo "	   release     - performs a release"
+	@echo "	   auto        - continuous builds"
+
+release: clean test upload-doc
+	python setup.py sdist upload
+
+dist: clean
+	python setup.py sdist
+
+build: doc
+	@bin/python setup.py build
+
+docs: doc
+
+doc: # develop
+	@make SPHINXBUILD=../bin/sphinx-build -C docs/ html
+
+upload-doc: doc
+	@bin/python setup.py upload_docs --upload-dir=docs/build/html
+
+view-doc: doc
+	@bin/python -c "import webbrowser; webbrowser.open('docs/build/html/index.html')"
+
+test: docs
+	@bin/coverage erase
+	@bin/python-tests tests/run_tests.py
+	@bin/coverage html -d htmlcov
+
+lint:
+	@pylint $(PKG_NAME)
+
+auto: tools/nosy.py
+	@bin/python tools/nosy.py .
+
+# Development environment targets and dependencies.
+develop: submodules bin/python
+
+submodules:
+	@git submodule update --init --recursive
+
+bin/buildout: buildout.cfg setup.py
+	@python tools/bootstrap.py --distribute
+
+bin/python: bin/buildout
+	@bin/buildout
+
+clean:
+	@make -C docs/ clean > /dev/null
+	@$(RM) build/ *.egg-info/
+	@find . \( \
+		-iname "*.pyc" \
+		-or -iname "*.pyo" \
+		-or -iname "*.so" \
+		-or -iname "*.o" \
+		-or -iname "*~" \
+		-or -iname "._*" \
+		-or -iname "*.swp" \
+		-or -iname "Desktop.ini" \
+		-or -iname "Thumbs.db" \
+		-or -iname "__MACOSX__" \
+		-or -iname ".DS_Store" \
+		\) -delete
+
+distclean: clean
+	@$(RM) \
+		dist/ \
+		bin/ \
+		develop-eggs/ \
+		eggs/ \
+		parts/ \
+		MANIFEST \
+		htmlcov/ \
+		.pythoscope/ \
+		.coverage \
+		.installed.cfg
+[nosetests]
+verbosity=3
+with-doctest=1
+#with-color=1
+#with-noseexclude=1
+#exclude-dir-file=tests/nose-exclude.txt
 More information at http://github.com/gorakhargosh/mom
 """
 
+import sys
+
 from setuptools import setup
 
+install_requires = [
+    "PyCrypto >=2.3",
+    "pyasn1 >=0.0.13b",
+]
+if sys.version_info < (2, 6, 0):
+    install_requires.append("simplejson >= 2.1.6")
+
 setup(
     name="mom",
     version="0.0.1",
     platforms="any",
     packages=["mom"],
     include_package_data=True,
-    install_requires=[
-        "PyCrypto >=2.3",
-        "pyasn1 >=0.0.13b",
-        # "simplejson",  # For python 2.5
-    ],
+    install_requires=install_requires,
     keywords=' '.join([
         "python",
         "utilities",

File tools/nosy.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# nosy: continuous integration for watchdog
+#
+# Copyright (C) 2010 Yesudeep Mangalapilly <yesudeep@gmail.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+"""
+:module: nosy
+:synopsis: Rewrite of Jeff Winkler's nosy script tailored to testing watchdog
+:platform: OS-independent
+"""
+
+import os.path
+import sys
+import stat
+import time
+import subprocess
+from fnmatch import fnmatch
+
+
+def match_patterns(pathname, patterns):
+    """Returns ``True`` if the pathname matches any of the given patterns."""
+    for pattern in patterns:
+        if fnmatch(pathname, pattern):
+            return True
+    return False
+
+
+def filter_paths(pathnames, patterns=None, ignore_patterns=None):
+    """Filters from a set of paths based on acceptable patterns and
+    ignorable patterns."""
+    result = []
+    if patterns is None:
+        patterns = ['*']
+    if ignore_patterns is None:
+        ignore_patterns = []
+    for pathname in pathnames:
+        if match_patterns(pathname, patterns) and not match_patterns(pathname, ignore_patterns):
+            result.append(pathname)
+    return result
+
+
+def absolute_walker(pathname, recursive):
+    if recursive:
+        walk = os.walk
+    else:
+        def walk(_path):
+            try:
+                return next(os.walk(_path))
+            except NameError:
+                return os.walk(_path).next()
+    for root, directories, filenames in walk(pathname):
+        yield root
+        for directory in directories:
+            yield os.path.abspath(os.path.join(root, directory))
+        for filename in filenames:
+            yield os.path.abspath(os.path.join(root, filename))
+
+
+def glob_recursive(pathname, patterns=None, ignore_patterns=None):
+    full_paths = []
+    for root, _, filenames in os.walk(pathname):
+        for filename in filenames:
+            full_path = os.path.abspath(os.path.join(root, filename))
+            full_paths.append(full_path)
+    filepaths = filter_paths(full_paths, patterns, ignore_patterns)
+    return filepaths
+
+
+def check_sum(pathname='.', patterns=None, ignore_patterns=None):
+    checksum = 0
+    for f in glob_recursive(pathname, patterns, ignore_patterns):
+        stats = os.stat(f)
+        checksum += stats[stat.ST_SIZE] + stats[stat.ST_MTIME]
+    return checksum
+
+
+if __name__ == "__main__":
+    if len(sys.argv) > 1:
+        path = sys.argv[1]
+    else:
+        path = '.'
+
+    if len(sys.argv) > 2:
+        command = sys.argv[2]
+    else:
+        commands = [
+            # Build documentation automatically as well as the source code
+            # changes.
+            "make SPHINXBUILD=../bin/sphinx-build -C docs html",
+
+            # The reports coverage generates all by itself are more
+            # user-friendly than the ones which `nosetests --with-coverage`
+            # generates. Therefore, we call `coverage` explicitly to
+            # generate reports, and to keep the reports in synchronization
+            # with the source code, we erase all coverage information
+            # before regenerating reports or running `nosetests`.
+            "bin/coverage erase",
+            "bin/python-tests tests/run_tests.py",
+            "bin/coverage html",
+        ]
+        command = '; '.join(commands)
+
+
+    previous_checksum = 0
+    while True:
+        calculated_checksum = check_sum(path, patterns=['*.py', '*.rst', '*.rst.inc'])
+        if calculated_checksum != previous_checksum:
+            previous_checksum = calculated_checksum
+            subprocess.Popen(command, shell=True)
+        time.sleep(2)
+
+
+