2013-05-03 08:14:14 +04:00
#!/usr/bin/env python
2013-05-22 02:20:26 +04:00
# Copyright (c) 2013 AnsibleWorks, Inc.
# All Rights Reserved.
2013-06-23 00:27:09 +04:00
import os , datetime , glob , sys
2013-06-26 03:46:12 +04:00
from distutils import log
2013-05-03 08:14:14 +04:00
from setuptools import setup , find_packages
2013-06-26 03:46:12 +04:00
from setuptools . command . sdist import sdist as _sdist
2013-05-03 08:14:14 +04:00
2013-06-23 21:21:02 +04:00
from awx import __version__
2013-05-03 08:14:14 +04:00
2013-06-24 21:03:33 +04:00
#build_timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M')
build_timestamp = os . getenv ( " BUILD " , datetime . datetime . now ( ) . strftime ( ' - % Y % m %d % H % M ' ) )
2013-05-22 01:39:34 +04:00
2013-06-15 12:10:11 +04:00
# Paths we'll use later
2013-06-23 21:21:02 +04:00
etcpath = " /etc/awx "
homedir = " /var/lib/awx "
2013-06-15 12:10:11 +04:00
if os . path . exists ( " /etc/debian_version " ) :
webconfig = " /etc/apache2/conf.d "
else :
webconfig = " /etc/httpd/conf.d "
#####################################################################
# Helper Functions
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:27:09 +04:00
2013-06-23 00:30:17 +04:00
# If running in a virtualenv, don't return data files that would install to
2013-06-23 00:27:09 +04:00
# 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
#####################################################################
2013-06-26 03:46:12 +04:00
class sdist_awx ( _sdist , object ) :
'''
Custom sdist command to distribute some files as . pyc only .
'''
def make_release_tree ( self , base_dir , files ) :
for f in files [ : ] :
if f . endswith ( ' .egg-info/SOURCES.txt ' ) :
files . remove ( f )
sources_txt_path = f
super ( sdist_awx , self ) . make_release_tree ( base_dir , files )
new_sources_path = os . path . join ( base_dir , sources_txt_path )
if os . path . isfile ( new_sources_path ) :
log . warn ( ' unlinking previous %s ' , new_sources_path )
os . unlink ( new_sources_path )
log . info ( ' writing new %s ' , new_sources_path )
new_sources = file ( new_sources_path , ' w ' )
for line in file ( sources_txt_path , ' r ' ) :
line = line . strip ( )
if line in self . pyc_only_files :
line = line + ' c '
new_sources . write ( line + ' \n ' )
def make_distribution ( self ) :
self . pyc_only_files = [ ]
import py_compile
for n , f in enumerate ( self . filelist . files [ : ] ) :
if not f . startswith ( ' awx/ ' ) :
continue
if f . startswith ( ' awx/lib/site-packages ' ) :
continue
if f . startswith ( ' awx/scripts ' ) :
continue
if f . startswith ( ' awx/plugins ' ) :
continue
if f . endswith ( ' .py ' ) :
log . info ( ' using pyc for: %s ' , f )
py_compile . compile ( f , doraise = True )
self . filelist . files [ n ] = f + ' c '
self . pyc_only_files . append ( f )
super ( sdist_awx , self ) . make_distribution ( )
2013-05-03 08:14:14 +04:00
setup (
2013-06-23 21:21:02 +04:00
name = ' awx ' ,
2013-06-20 12:20:48 +04:00
version = __version__ . split ( " - " ) [ 0 ] , # FIXME: Should keep full version here?
2013-05-03 08:14:14 +04:00
author = ' AnsibleWorks, Inc. ' ,
author_email = ' support@ansibleworks.com ' ,
2013-06-23 21:21:02 +04:00
description = ' AWX: API, UI and Task Engine for Ansible ' ,
long_description = ' AWX provides a web-based user interface, REST API and '
' task engine built on top of Ansible ' ,
2013-05-03 08:14:14 +04:00
license = ' Proprietary ' ,
keywords = ' ansible ' ,
url = ' http://github.com/ansible/ansible-commander ' ,
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 ,
2013-06-23 23:40:07 +04:00
#install_requires=[
2013-06-24 05:04:55 +04:00
# 'Django>=1.4',
# 'PyYAML',
2013-06-23 23:40:07 +04:00
#],
2013-05-03 08:14:14 +04:00
setup_requires = [ ] ,
classifiers = [
' Development Status :: 4 - Beta ' ,
' 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 ( [
2013-06-24 21:03:33 +04:00
( " %s " % homedir , [ " config/wsgi.py " ,
2013-06-23 21:21:02 +04:00
" awx/static/favicon.ico " ,
2013-06-15 12:10:11 +04:00
] ) ,
2013-09-07 22:58:50 +04:00
( " %s " % webconfig , [ " config/awx.conf " , " config/awx-plain.conf " ] ) ,
2013-06-15 12:10:11 +04:00
]
) ,
2013-06-26 03:46:12 +04:00
options = {
2013-05-03 08:14:14 +04:00
' egg_info ' : {
2013-06-26 15:33:09 +04:00
' tag_build ' : ' - %s ' % build_timestamp ,
2013-05-03 08:14:14 +04:00
} ,
' aliases ' : {
2013-06-26 03:46:12 +04:00
' dev_build ' : ' clean --all egg_info sdist_awx ' ,
' release_build ' : ' clean --all egg_info -b " " sdist_awx ' ,
2013-05-03 08:14:14 +04:00
} ,
} ,
2013-06-26 03:46:12 +04:00
cmdclass = {
' sdist_awx ' : sdist_awx ,
} ,
2013-05-03 08:14:14 +04:00
)