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
|
|
|
try: |
24
|
|
|
from setuptools import setup |
25
|
|
|
except ImportError: |
26
|
|
|
from distutils.core import setup |
27
|
|
|
|
28
|
|
|
import os |
29
|
|
|
import re |
30
|
|
|
import codecs |
31
|
|
|
|
32
|
|
|
here = os.path.abspath(os.path.dirname(__file__)) |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
def find_version(*paths): |
36
|
|
|
"""Read the version number from a source file.""" |
37
|
|
|
# Open in Latin-1 so that we avoid encoding errors. |
38
|
|
|
# Use codecs.open for Python 2 compatibility |
39
|
|
|
with codecs.open(os.path.join(here, *paths), 'r', 'latin1') as f: |
40
|
|
|
version_file = f.read() |
41
|
|
|
|
42
|
|
|
# The version line must have the form |
43
|
|
|
# __version__ = 'ver' |
44
|
|
|
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", |
45
|
|
|
version_file, re.M) |
46
|
|
|
if version_match: |
47
|
|
|
return version_match.group(1) |
48
|
|
|
raise RuntimeError('Unable to find version string') |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
def read_description(*paths): |
52
|
|
|
"""Build a file path from *paths* and return the contents.""" |
53
|
|
|
with open(os.path.join(*paths), 'r') as f: |
54
|
|
|
return f.read() |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
def read_requirements(filename): |
58
|
|
|
try: |
59
|
|
|
with open(filename) as f: |
60
|
|
|
return f.read().splitlines() |
61
|
|
|
except IOError: |
62
|
|
|
raise IOError(os.getcwd()) |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
setup( |
66
|
|
|
name='habrahabr-api', |
67
|
|
|
version=find_version('habrahabr', '__init__.py'), |
68
|
|
|
url='https://github.com/dotzero/habrahabr-api-python', |
69
|
|
|
description='A python implementation of the Habrahabr.ru API', |
70
|
|
|
long_description=read_description('README.md'), |
71
|
|
|
author='dotzero', |
72
|
|
|
author_email='[email protected]', |
73
|
|
|
license='MIT', |
74
|
|
|
packages=['habrahabr'] |
75
|
|
|
) |
76
|
|
|
|