Update project maturity status
[multicloud/azure.git] / azure / aria / aria-extension-cloudify / src / aria / setup.py
1 #!/usr/bin/env python
2 # Licensed to the Apache Software Foundation (ASF) under one or more
3 # contributor license agreements.  See the NOTICE file distributed with
4 # this work for additional information regarding copyright ownership.
5 # The ASF licenses this file to You under the Apache License, Version 2.0
6 # (the "License"); you may not use this file except in compliance with
7 # the License.  You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 import os
18 import sys
19
20 from setuptools import setup, find_packages
21 from setuptools.command.install import install
22 from setuptools.command.develop import develop
23
24
25 _PACKAGE_NAME = 'apache-ariatosca'
26 _PYTHON_SUPPORTED_VERSIONS = [(2, 6), (2, 7)]
27 _EXTENSION_DIR = 'extensions'
28 _EXTENSION_NAMES = [
29     'aria_extension_tosca'
30 ]
31
32 if (sys.version_info[0], sys.version_info[1]) not in _PYTHON_SUPPORTED_VERSIONS:
33     raise NotImplementedError(
34         '{0} Package support Python version 2.6 & 2.7 Only'.format(
35             _PACKAGE_NAME))
36
37 root_dir = os.path.dirname(__file__)
38
39 with open(os.path.join(root_dir, 'VERSION')) as version_file:
40     __version__ = version_file.read().strip()
41     incubating_version = '{0}-incubating'.format(__version__)
42
43 with open(os.path.join(root_dir, 'README.rst')) as readme:
44     long_description = readme.read()
45
46 install_requires = []
47
48 ssh_requires = [
49     'Fabric>=1.13.0, <1.14',
50 ]
51 win_ssh_requires = [
52     # Fabric depends on the pypiwin32 on Windows, but doesn't install it
53     'pypiwin32==219'
54 ]
55
56 extras_require = {
57     'ssh': ssh_requires,
58     'ssh:sys_platform=="win32"': win_ssh_requires
59 }
60
61 with open(os.path.join(root_dir, 'requirements.in')) as requirements:
62     for requirement in requirements.readlines():
63         requirement = requirement.split('#')[0].strip()  # get rid of comments or trailing comments
64         if not requirement:
65             continue  # skip empty and comment lines
66
67         # dependencies which use environment markers have to go in as conditional dependencies
68         # under "extra_require" rather than "install_requires", or otherwise the environment
69         # markers get ignored when installing from wheel. See more here:
70         # https://wheel.readthedocs.io/en/latest/index.html#defining-conditional-dependencies
71         # https://hynek.me/articles/conditional-python-dependencies/
72         if ';' in requirement:
73             package, condition = requirement.split(';')
74             cond_name = ':{0}'.format(condition.strip())
75             extras_require.setdefault(cond_name, [])
76             extras_require[cond_name].append(package.strip())
77         else:
78             install_requires.append(requirement)
79
80
81 console_scripts = ['aria = aria.cli.main:main']
82
83
84 def _generate_user_options(command):
85     return command.user_options + [
86         ('skip-ctx', None, 'Install with or without the ctx (Defaults to False)')
87     ]
88
89
90 def _generate_boolean_options(command):
91     return command.boolean_options + ['skip-ctx']
92
93
94 def _initialize_options(custom_cmd):
95     custom_cmd.command.initialize_options(custom_cmd)
96     custom_cmd.skip_ctx = False
97
98
99 def _run(custom_cmd):
100     if custom_cmd.skip_ctx is False:
101         console_scripts.append('ctx = aria.orchestrator.execution_plugin.ctx_proxy.client:main')
102     custom_cmd.command.run(custom_cmd)
103
104
105 class InstallCommand(install):
106     command = install
107
108     user_options = _generate_user_options(install)
109     boolean_options = _generate_boolean_options(install)
110     initialize_options = _initialize_options
111     run = _run
112
113
114 class DevelopCommand(develop):
115     command = develop
116
117     user_options = _generate_user_options(develop)
118     boolean_options = _generate_boolean_options(develop)
119     initialize_options = _initialize_options
120     run = _run
121
122 setup(
123     name=_PACKAGE_NAME,
124     version=__version__,
125     description='ARIA',
126     long_description=long_description,
127     license='Apache License 2.0',
128     author='ARIA',
129     author_email='dev@ariatosca.incubator.apache.org',
130     url='http://ariatosca.incubator.apache.org/',
131     download_url=(
132         'https://dist.apache.org/repos/dist/release/incubator/ariatosca/' + incubating_version),
133     classifiers=[
134         'Development Status :: 4 - Beta',
135         'Environment :: Console',
136         'Environment :: Web Environment',
137         'Intended Audience :: Developers',
138         'Intended Audience :: System Administrators',
139         'License :: OSI Approved :: Apache Software License',
140         'Operating System :: OS Independent',
141         'Programming Language :: Python',
142         'Programming Language :: Python :: 2',
143         'Programming Language :: Python :: 2.6',
144         'Programming Language :: Python :: 2.7',
145         'Topic :: Software Development :: Libraries :: Python Modules',
146         'Topic :: System :: Networking',
147         'Topic :: System :: Systems Administration'],
148     packages=find_packages(include=['aria*']) +
149              find_packages(where=_EXTENSION_DIR,
150                            include=['{0}*'.format(name) for name in _EXTENSION_NAMES]),
151     package_dir=dict((name, '{0}/{1}'.format(_EXTENSION_DIR, name)) for name in _EXTENSION_NAMES),
152     package_data={
153         'aria': [
154             'cli/config/config_template.yaml'
155         ],
156         'aria_extension_tosca': [
157             'profiles/tosca-simple-1.0/**',
158             'profiles/tosca-simple-nfv-1.0/**',
159             'profiles/aria-1.0/**',
160             'profiles/azure-plugin/**'
161         ]
162     },
163     platforms=['any'],
164     zip_safe=False,
165     install_requires=install_requires,
166     extras_require=extras_require,
167     entry_points={
168         'console_scripts': console_scripts
169     },
170     cmdclass={
171         'install': InstallCommand,      # used in pip install ...
172         'develop': DevelopCommand       # used in pip install -e ...
173     }
174 )