salt/setup.py

155 lines
5.2 KiB
Python
Raw Normal View History

2011-02-27 14:31:57 -07:00
#!/usr/bin/python2
'''
The setup script for salt
'''
2011-04-03 16:25:17 -06:00
import os
import sys
import unittest
from distutils import log
from distutils.cmd import Command
2011-02-27 14:31:57 -07:00
from distutils.core import setup
2011-04-03 16:25:17 -06:00
from distutils.extension import Extension
from distutils.sysconfig import get_python_lib, PREFIX
from Cython.Distutils import build_ext
2011-04-03 16:25:17 -06:00
NAME = 'salt'
2011-07-09 17:09:15 -06:00
VER = '0.8.9'
DESC = 'Portable, distrubuted, remote execution and configuration management system'
2011-04-03 16:25:17 -06:00
mod_path = os.path.join(get_python_lib(), 'salt/modules/')
doc_path = os.path.join(PREFIX, 'share/doc/', NAME + '-' + VER)
example_path = os.path.join(doc_path, 'examples')
template_path = os.path.join(example_path, 'templates')
if os.environ.has_key('SYSCONFDIR'):
etc_path = os.environ['SYSCONFDIR']
else:
etc_path = os.path.join(os.path.dirname(PREFIX), 'etc')
2011-02-27 14:31:57 -07:00
class UnitTest(Command):
description = "run unit tests"
user_options = []
def initialize_options(self):
self.test_dirs = None
def finalize_options(self):
if self.test_dirs is None:
self.test_dirs = ["test"]
def run(self):
errors = 0
failures = 0
for path in self.test_dirs:
for root, dirs, files in os.walk(path):
for filename in files:
if filename.startswith("test_") and \
filename.endswith(".py"):
results = self._run_test(os.path.join(root, filename))
errors += results[0]
failures += results[1]
self.announce(
"unit test: {} errors and {} failures".format(errors, failures),
level=log.INFO)
def _run_test(self, path):
self.announce("run tests in " + path, log.INFO)
dirname, basename = os.path.split(path)
sys.path.insert(0, dirname)
try:
modname = os.path.splitext(basename)[0]
mod = __import__(modname)
if hasattr(mod, "test_suite"):
suite = mod.test_suite()
runner = unittest.TextTestRunner(verbosity=2)
results = runner.run(suite)
return len(results.errors), len(results.failures)
else:
return (0, 0)
finally:
if sys.path[0] == dirname:
del sys.path[0]
setup(
name=NAME,
version=VER,
2011-08-02 23:05:52 -06:00
ext_modules=[
Extension('salt.modules.grains', ['salt/modules/grains.pyx']),
Extension('salt.modules.cytest', ['salt/modules/cytest.pyx']),
],
cmdclass={
'test':UnitTest,
'build_ext': build_ext,
},
description=DESC,
2011-02-27 14:31:57 -07:00
author='Thomas S Hatch',
author_email='thatch45@gmail.com',
url='https://github.com/thatch45/salt',
2011-05-06 08:28:34 -06:00
classifiers = [
'Programming Language :: Python',
'Programming Language :: Cython',
2011-07-09 17:09:15 -06:00
'Programming Language :: Python :: 2.5',
2011-05-06 08:28:34 -06:00
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Topic :: System :: Monitoring',
'Topic :: System :: Clustering',
'Topic :: System :: Distributed Computing',
],
2011-04-01 23:38:20 -06:00
packages=['salt',
'salt.modules',
2011-04-16 14:48:13 -06:00
'salt.cli',
'salt.returners',
2011-05-12 12:05:00 -06:00
'salt.renderers',
'salt.runners',
2011-04-29 16:07:53 -06:00
'salt.grains',
'salt.states',
'salt.utils',
2011-04-16 14:48:13 -06:00
],
2011-02-27 14:31:57 -07:00
scripts=['scripts/salt-master',
2011-03-09 10:52:22 -07:00
'scripts/salt-minion',
'scripts/salt-monitor',
2011-07-30 22:24:08 -06:00
'scripts/salt-syndic',
'scripts/salt-key',
2011-04-12 20:26:04 -06:00
'scripts/salt-cp',
2011-04-23 14:34:46 -06:00
'scripts/salt-call',
'scripts/salt-run',
2011-03-09 10:52:22 -07:00
'scripts/salt'],
data_files=[(os.path.join(etc_path, 'salt'),
2011-03-03 10:57:11 -07:00
['conf/master',
'conf/minion',
'conf/monitor',
2011-02-27 14:31:57 -07:00
]),
2011-04-01 23:22:19 -06:00
('share/man/man1',
['doc/man/salt-master.1',
'doc/man/salt-key.1',
'doc/man/salt.1',
'doc/man/salt-cp.1',
2011-07-09 17:09:15 -06:00
'doc/man/salt-run.1',
'doc/man/salt-minion.1',
'doc/man/salt-monitor.1',
2011-04-01 23:38:20 -06:00
]),
2011-04-01 23:22:19 -06:00
('share/man/man7',
['doc/man/salt.7',
2011-04-01 23:38:20 -06:00
]),
2011-04-03 16:25:17 -06:00
(mod_path,
['salt/modules/cytest.pyx',
]),
(doc_path,
2011-07-27 19:30:30 -06:00
['LICENSE'
]),
(template_path,
['doc/example/templates/yaml-jinja.yml',
2011-05-14 17:17:00 -06:00
'doc/example/templates/yaml-mako.yml',
'doc/example/templates/yaml.yml',
'doc/example/templates/json-jinja.json',
'doc/example/templates/json-mako.json',
'doc/example/templates/json.json',
]),
2011-02-27 14:31:57 -07:00
],
)