1#!/usr/bin/env python
2
3#-------------------------------------------------------------------------
4# Copyright (c) Microsoft Corporation. All rights reserved.
5# Licensed under the MIT License. See License.txt in the project root for
6# license information.
7#--------------------------------------------------------------------------
8
9import re
10import os.path
11from io import open
12from setuptools import find_packages, setup
13
14# Change the PACKAGE_NAME only to change folder and different name
15PACKAGE_NAME = "azure-mgmt-cognitiveservices"
16PACKAGE_PPRINT_NAME = "Cognitive Services Management"
17
18# a-b-c => a/b/c
19package_folder_path = PACKAGE_NAME.replace('-', '/')
20# a-b-c => a.b.c
21namespace_name = PACKAGE_NAME.replace('-', '.')
22
23# azure v0.x is not compatible with this package
24# azure v0.x used to have a __version__ attribute (newer versions don't)
25try:
26    import azure
27    try:
28        ver = azure.__version__
29        raise Exception(
30            'This package is incompatible with azure=={}. '.format(ver) +
31            'Uninstall it with "pip uninstall azure".'
32        )
33    except AttributeError:
34        pass
35except ImportError:
36    pass
37
38# Version extraction inspired from 'requests'
39with open(os.path.join(package_folder_path, 'version.py')
40          if os.path.exists(os.path.join(package_folder_path, 'version.py'))
41          else os.path.join(package_folder_path, '_version.py'), 'r') as fd:
42    version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
43                        fd.read(), re.MULTILINE).group(1)
44
45if not version:
46    raise RuntimeError('Cannot find version information')
47
48with open('README.md', encoding='utf-8') as f:
49    readme = f.read()
50with open('CHANGELOG.md', encoding='utf-8') as f:
51    changelog = f.read()
52
53setup(
54    name=PACKAGE_NAME,
55    version=version,
56    description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME),
57    long_description=readme + '\n\n' + changelog,
58    long_description_content_type='text/markdown',
59    license='MIT License',
60    author='Microsoft Corporation',
61    author_email='azpysdkhelp@microsoft.com',
62    url='https://github.com/Azure/azure-sdk-for-python',
63    classifiers=[
64        'Development Status :: 5 - Production/Stable',
65        'Programming Language :: Python',
66        'Programming Language :: Python :: 2',
67        'Programming Language :: Python :: 2.7',
68        'Programming Language :: Python :: 3',
69        'Programming Language :: Python :: 3.5',
70        'Programming Language :: Python :: 3.6',
71        'Programming Language :: Python :: 3.7',
72        'Programming Language :: Python :: 3.8',
73        'License :: OSI Approved :: MIT License',
74    ],
75    zip_safe=False,
76    packages=find_packages(exclude=[
77        'tests',
78        # Exclude packages that will be covered by PEP420 or nspkg
79        'azure',
80        'azure.mgmt',
81    ]),
82    install_requires=[
83        'msrest>=0.6.21',
84        'azure-common~=1.1',
85        'azure-mgmt-core>=1.2.0,<2.0.0',
86    ],
87    extras_require={
88        ":python_version<'3.0'": ['azure-mgmt-nspkg'],
89    }
90)
91