2012-07-01 01:54:25 +00:00
|
|
|
#!/usr/bin/env python
|
2011-02-27 22:17:45 +00:00
|
|
|
'''
|
|
|
|
The setup script for salt
|
|
|
|
'''
|
2011-11-14 15:49:06 +00:00
|
|
|
|
2012-05-07 03:25:14 +00:00
|
|
|
# For Python 2.5. A no-op on 2.6 and above.
|
|
|
|
from __future__ import with_statement
|
|
|
|
|
2011-12-10 20:12:16 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2011-07-22 17:47:34 +00:00
|
|
|
from distutils.cmd import Command
|
2011-05-23 18:23:42 +00:00
|
|
|
from distutils.sysconfig import get_python_lib, PREFIX
|
2011-12-22 22:56:33 +00:00
|
|
|
|
2012-07-01 02:00:22 +00:00
|
|
|
# Use setuptools only if the user opts-in by setting the USE_SETUPTOOLS env var
|
|
|
|
# This ensures consistent behavior but allows for advanced usage with
|
|
|
|
# virtualenv, buildout, and others.
|
2012-06-30 20:01:57 +00:00
|
|
|
with_setuptools = False
|
2012-07-01 02:00:22 +00:00
|
|
|
if 'USE_SETUPTOOLS' in os.environ:
|
2012-06-30 20:01:57 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup
|
|
|
|
with_setuptools = True
|
|
|
|
except:
|
|
|
|
with_setuptools = False
|
|
|
|
|
2012-07-09 04:50:12 +00:00
|
|
|
if with_setuptools is False:
|
2012-06-05 10:00:20 +00:00
|
|
|
from distutils.core import setup
|
|
|
|
|
2012-07-01 02:47:05 +00:00
|
|
|
salt_version = os.path.join(os.path.abspath(
|
|
|
|
os.path.dirname(__file__)), 'salt', 'version.py')
|
|
|
|
|
|
|
|
salt_reqs = os.path.join(os.path.abspath(
|
|
|
|
os.path.dirname(__file__)), 'requirements.txt')
|
|
|
|
|
|
|
|
exec(compile(open(salt_version).read(), salt_version, 'exec'))
|
2011-09-25 06:30:36 +00:00
|
|
|
|
2012-06-30 20:35:31 +00:00
|
|
|
|
2011-12-22 01:36:26 +00:00
|
|
|
class TestCommand(Command):
|
|
|
|
description = 'Run tests'
|
|
|
|
user_options = []
|
2012-06-30 20:35:31 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
2011-12-22 01:36:26 +00:00
|
|
|
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 = 'python %s' % runner
|
|
|
|
print("running test")
|
|
|
|
test_process = Popen(
|
|
|
|
test_cmd, shell=True,
|
|
|
|
stdout=sys.stdout, stderr=sys.stderr,
|
|
|
|
cwd=build_cmd.build_lib
|
|
|
|
)
|
|
|
|
test_process.communicate()
|
2012-05-05 11:53:39 +00:00
|
|
|
sys.exit(test_process.returncode)
|
2011-12-22 01:36:26 +00:00
|
|
|
|
2011-05-12 15:08:43 +00:00
|
|
|
NAME = 'salt'
|
2011-09-25 06:30:36 +00:00
|
|
|
VER = __version__
|
2011-11-09 14:12:15 +00:00
|
|
|
DESC = ('Portable, distributed, remote execution and '
|
|
|
|
'configuration management system')
|
2012-01-22 04:39:39 +00:00
|
|
|
mod_path = os.path.join(get_python_lib(), 'salt/modules')
|
2011-10-24 22:13:47 +00:00
|
|
|
doc_path = os.path.join(PREFIX, 'share/doc', NAME + '-' + VER)
|
2011-05-12 15:08:43 +00:00
|
|
|
example_path = os.path.join(doc_path, 'examples')
|
|
|
|
template_path = os.path.join(example_path, 'templates')
|
2011-11-09 11:57:51 +00:00
|
|
|
|
|
|
|
if 'SYSCONFDIR' in os.environ:
|
2011-05-24 02:00:14 +00:00
|
|
|
etc_path = os.environ['SYSCONFDIR']
|
|
|
|
else:
|
|
|
|
etc_path = os.path.join(os.path.dirname(PREFIX), 'etc')
|
2011-02-27 21:31:57 +00:00
|
|
|
|
2011-12-10 20:12:16 +00:00
|
|
|
libraries = ['ws2_32'] if sys.platform == 'win32' else []
|
|
|
|
|
2012-06-30 20:35:31 +00:00
|
|
|
requirements = ''
|
2012-07-01 02:47:05 +00:00
|
|
|
with open(salt_reqs) as f:
|
2012-03-02 00:17:03 +00:00
|
|
|
requirements = f.read()
|
|
|
|
|
2012-06-05 10:00:20 +00:00
|
|
|
|
|
|
|
setup_kwargs = {'name': NAME,
|
|
|
|
'version': VER,
|
|
|
|
'description': DESC,
|
|
|
|
'author': 'Thomas S Hatch',
|
|
|
|
'author_email': 'thatch45@gmail.com',
|
|
|
|
'url': 'http://saltstack.org',
|
|
|
|
'cmdclass': {'test': TestCommand},
|
|
|
|
'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',
|
2012-07-09 04:50:12 +00:00
|
|
|
('License :: OSI Approved ::'
|
|
|
|
' Apache Software License'),
|
2012-06-05 10:00:20 +00:00
|
|
|
'Operating System :: POSIX :: Linux',
|
|
|
|
'Topic :: System :: Clustering',
|
|
|
|
'Topic :: System :: Distributed Computing',
|
|
|
|
],
|
|
|
|
'packages': ['salt',
|
|
|
|
'salt.cli',
|
|
|
|
'salt.ext',
|
|
|
|
'salt.grains',
|
|
|
|
'salt.modules',
|
2012-07-08 05:57:08 +00:00
|
|
|
'salt.pillar',
|
2012-06-05 10:00:20 +00:00
|
|
|
'salt.renderers',
|
|
|
|
'salt.returners',
|
|
|
|
'salt.runners',
|
|
|
|
'salt.states',
|
|
|
|
'salt.utils',
|
|
|
|
],
|
2012-07-09 04:50:12 +00:00
|
|
|
'package_data': {'salt.modules': ['rh_ip/*.jinja']},
|
2012-06-05 10:00:20 +00:00
|
|
|
'data_files': [('share/man/man1',
|
|
|
|
['doc/man/salt-master.1',
|
|
|
|
'doc/man/salt-key.1',
|
|
|
|
'doc/man/salt.1',
|
|
|
|
'doc/man/salt-cp.1',
|
|
|
|
'doc/man/salt-call.1',
|
|
|
|
'doc/man/salt-syndic.1',
|
|
|
|
'doc/man/salt-run.1',
|
|
|
|
'doc/man/salt-minion.1',
|
2012-07-09 04:50:12 +00:00
|
|
|
]),
|
2012-06-05 10:00:20 +00:00
|
|
|
('share/man/man7', ['doc/man/salt.7']),
|
|
|
|
],
|
|
|
|
'install_requires': requirements,
|
2012-09-10 18:27:40 +00:00
|
|
|
# The dynamic module loading in salt.modules makes this
|
|
|
|
# package zip unsafe.
|
|
|
|
'zip_safe': False
|
2012-06-05 10:00:20 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 18:27:40 +00:00
|
|
|
|
|
|
|
# bbfreeze explicit includes
|
|
|
|
# Sometimes the auto module traversal doesn't find everything, so we
|
|
|
|
# explicitly add it. The auto dependency tracking especially does not work for
|
|
|
|
# imports occurring in salt.modules, as they are loaded at salt runtime.
|
|
|
|
# Specifying includes that don't exist doesn't appear to cause a freezing
|
|
|
|
# error.
|
|
|
|
freezer_includes = [
|
|
|
|
'zmq.core.*',
|
|
|
|
'zmq.utils.*',
|
|
|
|
'ast',
|
|
|
|
]
|
|
|
|
|
2012-09-18 20:35:38 +00:00
|
|
|
if sys.platform.startswith('win'):
|
2012-09-10 18:27:40 +00:00
|
|
|
freezer_includes.extend([
|
2012-09-18 20:35:38 +00:00
|
|
|
'win32api',
|
2012-09-10 18:27:40 +00:00
|
|
|
'win32con',
|
|
|
|
'win32security',
|
2012-09-18 20:35:38 +00:00
|
|
|
'ntsecuritycon',
|
|
|
|
'_winreg'
|
2012-09-10 18:27:40 +00:00
|
|
|
])
|
|
|
|
elif sys.platform.startswith('linux'):
|
|
|
|
freezer_includes.extend([
|
|
|
|
'yum'
|
|
|
|
])
|
|
|
|
|
|
|
|
if 'bdist_esky' in sys.argv:
|
|
|
|
# Add the esky bdist target if the module is available
|
|
|
|
# may require additional modules depending on platform
|
|
|
|
from esky import bdist_esky
|
|
|
|
# bbfreeze chosen for its tight integration with distutils
|
|
|
|
import bbfreeze
|
|
|
|
options = setup_kwargs.get('options', {})
|
|
|
|
options['bdist_esky'] = {
|
|
|
|
"freezer_module": "bbfreeze",
|
|
|
|
"freezer_options": {
|
|
|
|
"includes": freezer_includes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setup_kwargs['options'] = options
|
|
|
|
|
2012-06-05 10:00:20 +00:00
|
|
|
if with_setuptools:
|
|
|
|
setup_kwargs['entry_points'] = {
|
2012-07-09 04:50:12 +00:00
|
|
|
"console_scripts": ["salt-master = salt.scripts:salt_master",
|
2012-06-05 10:00:20 +00:00
|
|
|
"salt-minion = salt.scripts:salt_minion",
|
|
|
|
"salt-syndic = salt.scripts:salt_syndic",
|
|
|
|
"salt-key = salt.scripts:salt_key",
|
|
|
|
"salt-cp = salt.scripts:salt_cp",
|
|
|
|
"salt-call = salt.scripts:salt_call",
|
|
|
|
"salt-run = salt.scripts:salt_run",
|
|
|
|
"salt = salt.scripts:salt_main"
|
|
|
|
],
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
setup_kwargs['scripts'] = ['scripts/salt-master',
|
|
|
|
'scripts/salt-minion',
|
|
|
|
'scripts/salt-syndic',
|
|
|
|
'scripts/salt-key',
|
|
|
|
'scripts/salt-cp',
|
|
|
|
'scripts/salt-call',
|
|
|
|
'scripts/salt-run',
|
|
|
|
'scripts/salt']
|
|
|
|
|
|
|
|
setup(**setup_kwargs)
|