forked from ansible/ansible-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
94 lines (85 loc) · 3.14 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
import os
import sys
import shlex
import shutil
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.command.sdist import sdist as SDistCommand
from pip.req import parse_requirements
import container
class PlaybookAsTests(TestCommand):
user_options = [('ansible-args=', None, "Extra ansible arguments")]
def initialize_options(self):
self.ansible_args = u''
TestCommand.initialize_options(self)
def run(self):
if sys.platform == 'darwin':
# Docker for Mac exports certain paths into the virtual machine
# actually running Docker. The default tempdir isn't one of them,
# but /tmp is.
os.environ['TMPDIR'] = '/tmp'
return TestCommand.run(self)
def run_tests(self):
import subprocess
p = subprocess.Popen(
['ansible-playbook'] +
shlex.split(self.ansible_args) +
['run_tests.yml'],
cwd=os.path.join(os.getcwd(), 'test'),
)
rc = p.wait()
sys.exit(rc)
class BundleConductorFiles(SDistCommand):
def run(self):
shutil.copyfile('./setup.py', 'container/docker/files/setup.py')
shutil.copyfile('./conductor-requirements.txt',
'container/docker/files/conductor-requirements.txt')
shutil.copyfile('./conductor-requirements.yml',
'container/docker/files/conductor-requirements.yml')
return SDistCommand.run(self)
if container.ENV == 'host':
install_reqs = parse_requirements('requirements.txt', session=False)
setup_kwargs = dict(
install_requires=[str(ir.req) for ir in install_reqs if ir.match_markers()],
tests_require=[
'ansible>=2.3.0',
'pytest>=3',
'docker>=2.1',
'jmespath>=0.9'
],
extras_require={
'docker': ['docker>=2.1'],
'docbuild': ['Sphinx>=1.5.0'],
'openshift': ['openshift==0.0.1'],
'k8s': ['openshift==0.0.1']
},
#dependency_links=[
# 'https://github.com/ansible/ansible/archive/devel.tar.gz#egg=ansible-2.4.0',
#],
cmdclass={'test': PlaybookAsTests,
'sdist': BundleConductorFiles},
entry_points={
'console_scripts': [
'ansible-container = container.cli:host_commandline']
}
)
else:
setup_kwargs = dict(
entry_points={
'console_scripts': ['conductor = container.cli:conductor_commandline']
},
)
setup(
name='ansible-container',
version=container.__version__,
packages=find_packages(include='container.*'),
include_package_data=True,
zip_safe=False,
url='https://github.com/ansible/ansible-container',
license='LGPLv3 (See LICENSE file for terms)',
author='Joshua "jag" Ginsberg, Chris Houseknecht, and others (See AUTHORS file for contributors)',
author_email='[email protected]',
description=('Ansible Container empowers you to orchestrate, build, run, and ship '
'Docker images built from Ansible playbooks.'),
**setup_kwargs
)