1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00
awx/setup.py

181 lines
5.9 KiB
Python
Raw Normal View History

2013-05-03 08:14:14 +04:00
#!/usr/bin/env python
2015-06-11 23:05:30 +03:00
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.
import os
import glob
import sys
import subprocess
from setuptools import setup
from distutils.command.sdist import sdist
2013-06-15 12:10:11 +04:00
# Paths we'll use later
2016-03-23 22:46:00 +03:00
etcpath = "/etc/tower"
2013-06-23 21:21:02 +04:00
homedir = "/var/lib/awx"
2016-03-23 22:46:00 +03:00
bindir = "/usr/bin"
sharedir = "/usr/share/awx"
2017-08-03 23:18:55 +03:00
docdir = "/usr/share/doc/awx"
2017-07-24 22:12:24 +03:00
def get_version():
current_dir = os.path.dirname(os.path.abspath(__file__))
version_file = os.path.join(current_dir, 'VERSION')
if os.path.isfile(version_file):
with open(version_file, 'r') as file:
version = file.read().strip()
else:
version = subprocess.Popen("git describe --long | cut -d - -f 1-1", shell=True, stdout=subprocess.PIPE).stdout.read().strip()
return version
2013-06-15 12:10:11 +04:00
if os.path.exists("/etc/debian_version"):
sysinit = "/etc/init.d"
2016-10-07 21:41:34 +03:00
webconfig = "/etc/nginx"
siteconfig = "/etc/nginx/sites-enabled"
# sosreport-3.1 (and newer) look in '/usr/share/sosreport/sos/plugins'
# sosreport-3.0 looks in '/usr/lib/python2.7/dist-packages/sos/plugins'
# debian/<package>.links will create symlinks to support both versions
sosconfig = "/usr/share/sosreport/sos/plugins"
2013-06-15 12:10:11 +04:00
else:
sysinit = "/etc/rc.d/init.d"
2016-10-07 21:41:34 +03:00
webconfig = "/etc/nginx"
siteconfig = "/etc/nginx/sites-enabled"
# The .spec will create symlinks to support multiple versions of sosreport
sosconfig = "/usr/share/sosreport/sos/plugins"
2013-06-15 12:10:11 +04:00
#####################################################################
# Isolated packaging
#####################################################################
class sdist_isolated(sdist):
includes = [
2017-06-23 15:48:39 +03:00
'include Makefile',
'include awx/__init__.py',
'include awx/main/expect/run.py',
'include tools/scripts/awx-expect',
2017-06-23 15:48:39 +03:00
'include requirements/requirements_isolated.txt',
'recursive-include awx/lib *.py',
]
def __init__(self, dist):
sdist.__init__(self, dist)
dist.metadata.version = get_version()
def get_file_list(self):
self.filelist.process_template_line('include setup.py')
for line in self.includes:
self.filelist.process_template_line(line)
self.write_manifest()
def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
with open(os.path.join(base_dir, 'MANIFEST.in'), 'w') as f:
f.write('\n'.join(self.includes))
2013-06-15 12:10:11 +04:00
#####################################################################
# Helper Functions
2016-11-16 04:59:39 +03:00
2013-06-15 12:10:11 +04:00
def explode_glob_path(path):
"""Take a glob and hand back the full recursive expansion,
ignoring links.
"""
result = []
includes = glob.glob(path)
for item in includes:
if os.path.isdir(item) and not os.path.islink(item):
result.extend(explode_glob_path(os.path.join(item, "*")))
else:
result.append(item)
return result
def proc_data_files(data_files):
"""Because data_files doesn't natively support globs...
let's add them.
"""
result = []
2013-06-23 00:30:17 +04:00
# If running in a virtualenv, don't return data files that would install to
# system paths (mainly useful for running tests via tox).
if hasattr(sys, 'real_prefix'):
return result
2013-06-15 12:10:11 +04:00
for dir,files in data_files:
includes = []
for item in files:
includes.extend(explode_glob_path(item))
result.append((dir, includes))
return result
#####################################################################
2016-11-16 00:32:27 +03:00
2013-05-03 08:14:14 +04:00
setup(
name=os.getenv('NAME', 'awx'),
version=get_version(),
2014-01-29 21:30:12 +04:00
author='Ansible, Inc.',
author_email='info@ansible.com',
description='awx: API, UI and Task Engine for Ansible',
long_description='AWX provides a web-based user interface, REST API and '
2013-06-23 21:21:02 +04:00
'task engine built on top of Ansible',
license='MIT',
2013-05-03 08:14:14 +04:00
keywords='ansible',
url='http://github.com/ansible/awx',
2013-06-23 21:21:02 +04:00
packages=['awx'],
2013-05-03 08:14:14 +04:00
include_package_data=True,
zip_safe=False,
setup_requires=[],
classifiers=[
'Development Status :: 5 - Production/Stable',
2013-05-03 08:14:14 +04:00
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators'
'License :: Other/Proprietary License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: System :: Installation/Setup',
'Topic :: System :: Systems Administration',
],
entry_points = {
'console_scripts': [
2013-06-23 21:21:02 +04:00
'awx-manage = awx:manage',
2013-05-03 08:14:14 +04:00
],
},
2013-06-15 12:10:11 +04:00
data_files = proc_data_files([
("%s" % homedir, ["config/wsgi.py",
"awx/static/favicon.ico",
"awx/locale/*/LC_MESSAGES/*.po",
"awx/locale/*/LC_MESSAGES/*.mo"]),
2016-10-07 21:41:34 +03:00
("%s" % siteconfig, ["config/awx-nginx.conf"]),
2016-11-08 17:37:07 +03:00
# ("%s" % webconfig, ["config/uwsgi_params"]),
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh","tools/scripts/request_tower_configuration.ps1"]),
("%s" % docdir, ["docs/licenses/*",]),
2016-03-23 22:46:00 +03:00
("%s" % bindir, ["tools/scripts/ansible-tower-service",
"tools/scripts/failure-event-handler",
2017-07-25 18:49:21 +03:00
"tools/scripts/awx-python",
2017-03-23 05:58:11 +03:00
"tools/scripts/ansible-tower-setup"]),
("%s" % sosconfig, ["tools/sosreport/tower.py"])]),
cmdclass = {'sdist_isolated': sdist_isolated},
options = {
2013-05-03 08:14:14 +04:00
'aliases': {
'dev_build': 'clean --all egg_info sdist',
'release_build': 'clean --all egg_info -b "" sdist',
'isolated_build': 'clean --all egg_info -b "" sdist_isolated',
2013-05-03 08:14:14 +04:00
},
2016-03-23 22:46:00 +03:00
'build_scripts': {
2017-07-25 18:49:21 +03:00
'executable': '/usr/bin/awx-python',
2016-03-23 22:46:00 +03:00
},
2013-05-03 08:14:14 +04:00
},
)