-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
142 lines (123 loc) · 3.83 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import os
from setuptools import setup
from setuptools.command.test import test as TestCommand
from setuptools import Command
import subprocess
import sys
def get_data_files(directories):
build_docs()
paths = {}
for directory in directories:
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
if not path.startswith('code/scripts'):
if path not in paths.keys():
paths[path] = []
paths[path].append(os.path.join(path, filename))
data_files = []
for k in paths.keys():
dest_path = k
if dest_path.startswith('code/'):
dest_path = dest_path[len('code/'):]
if not dest_path.startswith('scripts/'):
data_files.append(('project-skeleton/validation_pipeline/' + dest_path, paths[k]))
return data_files
def build_docs(dest_path='code/docs'):
orig_path = os.getcwd()
for lib in ['awsclients', 'cfnpipeline', 'logger']:
sys.path.append('%s/code/lambda_functions/lib/%s' % (orig_path, lib))
try:
import pdoc
except ImportError:
import pip
pip.main(['install', 'pdoc'])
import pdoc
try:
import boto3
except ImportError:
import pip
pip.main(['install', 'boto3'])
import boto3
try:
os.mkdir(dest_path)
except OSError as e:
if e.errno == 17:
pass
else:
raise
for lib in ['awsclients', 'cfnpipeline', 'logger']:
f = open('%s/%s/%s.html' % (orig_path, dest_path, lib), 'w')
f.write(pdoc.html(lib))
f.close()
class DocGen(Command):
user_options = []
description = 'generate html docs with pdoc'
def initialize_options(self):
pass
def finalize_options(self):
pass
@staticmethod
def run():
build_docs('docs')
class CustomTestCommand(TestCommand):
description = 'run tests'
user_options = []
def run_tests(self):
self._run([sys.executable, '-m', 'unittest', 'discover', '-s', './code/tests'])
@staticmethod
def _run(command):
try:
subprocess.check_call(command)
except subprocess.CalledProcessError as error:
print('Command failed with exit code', error.returncode)
sys.exit(error.returncode)
setup(
name="aws_cloudformation_validation_pipeline",
version="0.0.2",
author="AWS Solutions Builder",
author_email="[email protected]",
description="Authoring package for AWS CloudFormation Template Validation Pipeline",
license="Amazon Software License 1.0",
keywords="cloudformation cicd aws pipeline",
url="https://github.com/awslabs/aws_cloudformation_validation_pipeline/",
scripts=[
'code/scripts/cfn-validation-pipeline-skeleton',
'code/scripts/cfn-validation-pipeline-deploy',
'code/scripts/cfn-validation-pipeline-cleanup',
'code/scripts/cfn-validation-pipeline-rollback'
],
data_files=get_data_files(
[
'code',
'cloudformation',
'demo_source'
]
),
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 2.7",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Topic :: Software Development :: Testing",
"Environment :: Console",
"Intended Audience :: Information Technology",
"License :: Amazon Software License :: 1.0",
],
zip_safe=False,
setup_requires=[
'pdoc'
],
install_requires=[
'boto3'
],
tests_require=[
'six',
'mock',
'boto3',
'pyyaml'
],
cmdclass={
'test': CustomTestCommand,
'build_docs': DocGen
}
)