2013-06-27 17:18:50 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
'''
|
2013-06-27 17:28:08 +00:00
|
|
|
Deploy salt-thin, salt deployed to be as small as possible
|
2013-06-27 17:18:50 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
# For Python 2.5. A no-op on 2.6 and above.
|
|
|
|
from __future__ import with_statement
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from distutils.cmd import Command
|
|
|
|
from distutils.command.clean import clean
|
|
|
|
from distutils.sysconfig import get_python_lib, PREFIX
|
|
|
|
from distutils.core import setup
|
|
|
|
|
|
|
|
# Change to salt source's directory prior to running any command
|
|
|
|
try:
|
|
|
|
setup_dirname = os.path.dirname(__file__)
|
|
|
|
except NameError:
|
|
|
|
# We're most likely being frozen and __file__ triggered this NameError
|
|
|
|
# Let's work around that
|
|
|
|
setup_dirname = os.path.dirname(sys.argv[0])
|
|
|
|
|
|
|
|
if setup_dirname != '':
|
|
|
|
os.chdir(setup_dirname)
|
|
|
|
|
|
|
|
salt_version = os.path.join(
|
|
|
|
os.path.abspath(setup_dirname), 'salt', 'version.py'
|
|
|
|
)
|
|
|
|
|
|
|
|
salt_reqs = os.path.join(
|
|
|
|
os.path.abspath(setup_dirname), 'requirements.thin.txt'
|
|
|
|
)
|
|
|
|
|
|
|
|
exec(compile(open(salt_version).read(), salt_version, 'exec'))
|
|
|
|
|
|
|
|
|
|
|
|
class TestCommand(Command):
|
|
|
|
description = 'Run tests'
|
|
|
|
user_options = [
|
|
|
|
('runtests-opts=', 'R', 'Command line options to pass to runtests.py')
|
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.runtests_opts = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
from subprocess import Popen
|
|
|
|
self.run_command('build')
|
|
|
|
build_cmd = self.get_finalized_command('build_ext')
|
|
|
|
runner = os.path.abspath('tests/runtests.py')
|
|
|
|
test_cmd = sys.executable + ' {0}'.format(runner)
|
|
|
|
if self.runtests_opts:
|
|
|
|
test_cmd += ' {0}'.format(self.runtests_opts)
|
|
|
|
|
|
|
|
print('running test')
|
|
|
|
test_process = Popen(
|
|
|
|
test_cmd, shell=True,
|
|
|
|
stdout=sys.stdout, stderr=sys.stderr,
|
|
|
|
cwd=build_cmd.build_lib
|
|
|
|
)
|
|
|
|
test_process.communicate()
|
|
|
|
sys.exit(test_process.returncode)
|
|
|
|
|
|
|
|
|
|
|
|
class Clean(clean):
|
|
|
|
def run(self):
|
|
|
|
clean.run(self)
|
|
|
|
# Let's clean compiled *.py[c,o]
|
|
|
|
remove_extensions = ('.pyc', '.pyo')
|
|
|
|
for subdir in ('salt', 'tests'):
|
|
|
|
root = os.path.join(os.path.dirname(__file__), subdir)
|
|
|
|
for dirname, dirnames, filenames in os.walk(root):
|
|
|
|
for filename in filenames:
|
|
|
|
for ext in remove_extensions:
|
|
|
|
if filename.endswith(ext):
|
|
|
|
os.remove(os.path.join(dirname, filename))
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
install_version_template = '''\
|
|
|
|
# This file was auto-generated by salt's setup on \
|
|
|
|
{date:%A, %d %B %Y @ %H:%m:%S UTC}.
|
|
|
|
|
|
|
|
__version__ = {version!r}
|
|
|
|
__version_info__ = {version_info!r}
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
NAME = 'salt-thin'
|
|
|
|
VER = __version__
|
|
|
|
DESC = ('Portable, distributed, remote execution and '
|
|
|
|
'configuration management system')
|
|
|
|
mod_path = os.path.join(get_python_lib(), 'salt/modules')
|
|
|
|
|
|
|
|
if 'SYSCONFDIR' in os.environ:
|
|
|
|
etc_path = os.environ['SYSCONFDIR']
|
|
|
|
else:
|
|
|
|
etc_path = os.path.join(os.path.dirname(PREFIX), 'etc')
|
|
|
|
|
|
|
|
with open(salt_reqs) as f:
|
|
|
|
lines = f.read().split('\n')
|
|
|
|
requirements = [line for line in lines if line]
|
|
|
|
|
|
|
|
|
|
|
|
setup_kwargs = {'name': NAME,
|
|
|
|
'version': VER,
|
|
|
|
'description': DESC,
|
|
|
|
'author': 'Thomas S Hatch',
|
|
|
|
'author_email': 'thatch45@gmail.com',
|
|
|
|
'url': 'http://saltstack.org',
|
|
|
|
'cmdclass': {
|
|
|
|
'test': TestCommand,
|
|
|
|
'clean': Clean,
|
|
|
|
},
|
|
|
|
'classifiers': ['Programming Language :: Python',
|
|
|
|
'Programming Language :: Cython',
|
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
'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 :: Clustering',
|
|
|
|
'Topic :: System :: Distributed Computing',
|
|
|
|
],
|
|
|
|
'packages': ['salt',
|
|
|
|
'salt.cli',
|
|
|
|
'salt.ext',
|
|
|
|
'salt.auth',
|
|
|
|
'salt.wheel',
|
|
|
|
'salt.tops',
|
|
|
|
'salt.grains',
|
|
|
|
'salt.modules',
|
|
|
|
'salt.pillar',
|
|
|
|
'salt.renderers',
|
|
|
|
'salt.returners',
|
|
|
|
'salt.runners',
|
|
|
|
'salt.states',
|
|
|
|
'salt.fileserver',
|
|
|
|
'salt.search',
|
|
|
|
'salt.output',
|
|
|
|
'salt.utils',
|
|
|
|
],
|
|
|
|
'package_data': {'salt.modules': ['rh_ip/*.jinja']},
|
|
|
|
# Required for esky builds
|
|
|
|
'install_requires': requirements,
|
|
|
|
# The dynamic module loading in salt.modules makes this
|
|
|
|
# package zip unsafe. Required for esky builds
|
|
|
|
'zip_safe': False
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setup_kwargs['scripts'] = ['scripts/salt-call',]
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
setup(**setup_kwargs)
|