Completed
Push — develop ( b2a3d2...6c10aa )
by A
01:07
created

latest_changes()   B

Complexity

Conditions 7

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
dl 0
loc 17
rs 7.3333
c 0
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
#
4
# Copyright (c) 2013-2016 Online SAS and Contributors. All Rights Reserved.
5
#                         Julien Castets <[email protected]>
6
#                         Kevin Deldycke <[email protected]>
7
#
8
# Licensed under the BSD 2-Clause License (the "License"); you may not use this
9
# file except in compliance with the License. You may obtain a copy of the
10
# License at https://opensource.org/licenses/BSD-2-Clause
11
12
from __future__ import (
13
    absolute_import,
14
    division,
15
    print_function,
16
    unicode_literals
17
)
18
19
import io
20
import re
21
import sys
22
from os import path
23
24
from setuptools import find_packages, setup
25
26
MODULE_NAME = 'scaleway'
27
PACKAGE_NAME = 'scaleway-sdk'
28
29
DEPENDENCIES = [
30
    'slumber >= 0.6.2',
31
    'six']
32
33
# Packages required to handle SNI, only for Python2.
34
if sys.version_info.major == 2:
35
    DEPENDENCIES += [
36
        'pyOpenSSL',
37
        'ndg-httpsclient',
38
        'pyasn1']
39
40
EXTRA_DEPENDENCIES = {
41
    # Extra dependencies are made available through the
42
    # `$ pip install .[keyword]` command.
43
    'tests': [
44
        'coverage',
45
        'httpretty >= 0.8.0',
46
        'mock',
47
        'nose',
48
        'pycodestyle >= 2.1.0',
49
        'pylint'],
50
    'develop': [
51
        'bumpversion',
52
        'isort',
53
        'readme_renderer',
54
        'setuptools >= 24.2.1'
55
        'wheel']}
56
57
58
def read_file(*relative_path_elements):
59
    """ Return content of a file relative to this ``setup.py``. """
60
    file_path = path.join(path.dirname(__file__), *relative_path_elements)
61
    return io.open(file_path, encoding='utf8').read().strip()
62
63
64
# Cache fetched version.
65
_version = None  # noqa
66
67
68
def version():
69
    """ Extract version from the ``__init__.py`` file at the module's root.
70
71
    Inspired by: https://packaging.python.org/single_source_version/
72
    """
73
    global _version
74
    if _version:
75
        return _version
76
    init_file = read_file(MODULE_NAME, '__init__.py')
77
    matches = re.search(
78
        r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', init_file, re.M)
79
    if not matches:
80
        raise RuntimeError("Unable to find version string in __init__.py .")
81
    _version = matches.group(1)  # noqa
82
    return _version
83
84
85
def latest_changes():
86
    """ Extract part of changelog pertaining to version. """
87
    lines = []
88
    for line in read_file('CHANGES.rst').splitlines():
89
        if line.startswith('-------'):
90
            if len(lines) > 1:
91
                lines = lines[:-1]
92
                break
93
        if lines:
94
            lines.append(line)
95
        elif line.startswith("`{} (".format(version())):
96
            lines.append(line)
97
    if not lines:
98
        raise RuntimeError(
99
            "Unable to find changelog for the {} release.".format(version()))
100
    # Renormalize and clean lines.
101
    return '\n'.join(lines).strip().split('\n')
102
103
104
def long_description():
105
    """ Collates project README and latest changes. """
106
    changes = latest_changes()
107
    changes[0] = "`Changes for v{}".format(changes[0][1:])
108
    changes[1] = '-' * len(changes[0])
109
    return "\n\n\n".join([
110
        read_file('README.rst'),
111
        '\n'.join(changes),
112
        "`Full changelog <https://github.com/scaleway/python-scaleway/blob/"
113
        "develop/CHANGES.rst#changelog>`_."])
114
115
setup(
116
    name=PACKAGE_NAME,
117
    version=version(),
118
    description="Python SDK to query Scaleway APIs.",
119
    long_description=long_description(),
120
    keywords=['network', 'compute', 'storage', 'api', 'sdk', 'cloud', 'iaas'],
121
122
    author='Scaleway',
123
    author_email='[email protected]',
124
    url='https://github.com/scaleway/python-scaleway',
125
    license='BSD',
126
127
    packages=find_packages(),
128
    # https://www.python.org/dev/peps/pep-0345/#version-specifiers
129
    python_requires='>= 2.7, != 3.0.*, != 3.1.*, != 3.2.*',
130
    install_requires=DEPENDENCIES,
131
    tests_require=DEPENDENCIES + EXTRA_DEPENDENCIES['tests'],
132
    extras_require=EXTRA_DEPENDENCIES,
133
    dependency_links=[],
134
    test_suite='{}.tests'.format(MODULE_NAME),
135
136
    classifiers=[
137
        # See: https://pypi.python.org/pypi?:action=list_classifiers
138
        'Development Status :: 5 - Production/Stable',
139
        'Environment :: Web Environment',
140
        'Intended Audience :: Developers',
141
        'Intended Audience :: Information Technology',
142
        'License :: OSI Approved :: BSD License',
143
        'Operating System :: OS Independent',
144
        # List of python versions and their support status:
145
        # https://en.wikipedia.org/wiki/CPython#Version_history
146
        'Programming Language :: Python',
147
        'Programming Language :: Python :: 2',
148
        'Programming Language :: Python :: 2.7',
149
        'Programming Language :: Python :: 3',
150
        'Programming Language :: Python :: 3.3',
151
        'Programming Language :: Python :: 3.4',
152
        'Programming Language :: Python :: 3.5',
153
        'Programming Language :: Python :: Implementation :: CPython',
154
        'Programming Language :: Python :: Implementation :: PyPy',
155
        'Topic :: Software Development :: Libraries :: Python Modules',
156
        'Topic :: Internet',
157
        'Topic :: System :: Distributed Computing',
158
    ],
159
160
    entry_points={
161
        'console_scripts': [],
162
    }
163
)
164