read_requirements()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
# -*- coding: utf-8 -*-
2
#
3
# Copyright (c) 2016 dotzero <[email protected]>
4
#
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
6
# of this software and associated documentation files (the "Software"), to deal
7
# in the Software without restriction, including without limitation the rights
8
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
# copies of the Software, and to permit persons to whom the Software is
10
# furnished to do so, subject to the following conditions:
11
#
12
# The above copyright notice and this permission notice shall be included in all
13
# copies or substantial portions of the Software.
14
#
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
# SOFTWARE.
22
23
import os
24
import re
25
import codecs
26
from setuptools import setup, find_packages
27
28
here = os.path.abspath(os.path.dirname(__file__))
29
30
31
def find_version(*paths):
32
    """Read the version number from a source file."""
33
    # Open in Latin-1 so that we avoid encoding errors.
34
    # Use codecs.open for Python 2 compatibility
35
    with codecs.open(os.path.join(here, *paths), 'r', 'latin1') as f:
36
        version_file = f.read()
37
38
    # The version line must have the form
39
    # __version__ = 'ver'
40
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
41
                              version_file, re.M)
42
    if version_match:
43
        return version_match.group(1)
44
    raise RuntimeError('Unable to find version string')
45
46
47
def read_description(*paths):
48
    """Build a file path from *paths* and return the contents."""
49
    with open(os.path.join(*paths), 'r') as f:
50
        return f.read()
51
52
53
def read_requirements(filename):
54
    try:
55
        with open(filename) as f:
56
            return f.read().splitlines()
57
    except IOError:
58
        raise IOError(os.getcwd())
59
60
61
setup(
62
    name='habrahabr-api',
63
    version=find_version('habrahabr', '__init__.py'),
64
    url='https://github.com/dotzero/habrahabr-api-python',
65
    description='A python implementation of the Habrahabr.ru API',
66
    long_description=read_description('README.rst'),
67
    author='dotzero',
68
    author_email='[email protected]',
69
    license='MIT',
70
    packages=find_packages(exclude=['tests*']),
71
)
72