Basic setuptools support
diff --git a/reclass.py.in b/reclass.py.in
deleted file mode 100644
index a2e036a..0000000
--- a/reclass.py.in
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# reclass — recursive external node classifier
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-__name__ = 'reclass'
-__description__ = 'classify nodes based on an external data source'
-__version__ = '1.0'
-__author__ = 'martin f. krafft <madduck@madduck.net>'
-__copyright__ = 'Copyright © 2007–13 ' + __author__
-__licence__ = 'Artistic Licence 2.0'
-
-import sys, os, posix
-import reclass.config
-from reclass.output import OutputLoader
-from reclass.storage import StorageBackendLoader
-import reclass.errors
-from reclass import get_data, output
-
-def _error(msg, rc):
- print >>sys.stderr, msg
- sys.exit(rc)
-
-config_file = None
-for d in (os.getcwd(), os.path.dirname(sys.argv[0])):
- f = os.path.join(d, __name__ + '-config.yml')
- if os.access(f, os.R_OK):
- config_file = f
- break
-try:
- defaults = { 'pretty_print' : True, 'output' : 'yaml' }
- options = reclass.config.get_options(__name__, __version__,
- __description__, config_file,
- defaults)
- nodes_uri, classes_uri = reclass.config.path_mangler(options.inventory_base_uri,
- options.nodes_uri,
- options.classes_uri)
- data = get_data(options.storage_type, nodes_uri, classes_uri,
- options.node)
- print output(data, options.output, options.pretty_print)
- sys.exit(posix.EX_OK)
-
-except reclass.errors.ReclassException, e:
- _error(e.message, e.rc)
diff --git a/reclass/main.py b/reclass/main.py
new file mode 100644
index 0000000..a1ee0a9
--- /dev/null
+++ b/reclass/main.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# reclass — recursive external node classifier
+#
+# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+__name__ = 'reclass'
+__description__ = 'classify nodes based on an external data source'
+__version__ = '1.0'
+__author__ = 'martin f. krafft <madduck@madduck.net>'
+__copyright__ = 'Copyright © 2007–13 ' + __author__
+__licence__ = 'Artistic Licence 2.0'
+
+import sys, os, posix
+import reclass.config
+from reclass.output import OutputLoader
+from reclass.storage import StorageBackendLoader
+import reclass.errors
+from reclass import get_data, output
+
+def _error(msg, rc):
+ print >>sys.stderr, msg
+ sys.exit(rc)
+
+def run():
+ config_file = None
+ for d in (os.getcwd(), os.path.dirname(sys.argv[0])):
+ f = os.path.join(d, __name__ + '-config.yml')
+ if os.access(f, os.R_OK):
+ config_file = f
+ break
+ try:
+ defaults = { 'pretty_print' : True, 'output' : 'yaml' }
+ options = reclass.config.get_options(__name__, __version__,
+ __description__, config_file,
+ defaults)
+ nodes_uri, classes_uri = reclass.config.path_mangler(options.inventory_base_uri,
+ options.nodes_uri,
+ options.classes_uri)
+ data = get_data(options.storage_type, nodes_uri, classes_uri,
+ options.node)
+ print output(data, options.output, options.pretty_print)
+ sys.exit(posix.EX_OK)
+
+ except reclass.errors.ReclassException, e:
+ _error(e.message, e.rc)
diff --git a/run_tests.py b/run_tests.py
deleted file mode 100755
index 7658f91..0000000
--- a/run_tests.py
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-import nose
-nose.main()
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9e5911f
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,11 @@
+from setuptools import setup, find_packages
+setup(
+ name = "Reclass",
+ version = "1.0",
+ packages = find_packages(),
+ entry_points = {
+ 'console_scripts': ['reclass = reclass.main:run' ],
+ },
+ install_requires = ['pyyaml'],
+ setup_requires = ['nose'],
+)