forked from jisaacstone/odata-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (64 loc) · 2.72 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# type: ignore
"""Setup script for package - config is under setup.cfg."""
import os
import sys
import configparser
import datetime
setup_kwargs = {}
from setuptools import find_packages, setup
try:
import pbr
setup_kwargs['pbr'] = True
except ImportError:
setup_kwargs['pbr'] = False
here = os.path.abspath(os.path.dirname(__file__))
basename = os.path.basename(os.path.dirname(__file__))
# give a list of scripts and how they map to a package module
CONSOLE_SCRIPTS = []
# load config using parser
parser = configparser.ConfigParser()
parser.read('%s/setup.cfg' % here)
install_requirements = [line.split('#')[0].strip(' ')
for line in open('%s/requirements.txt' % here).readlines()
if line and line.split('#')[0] and
not line.startswith('git+')] # can't currently handle git URLs unless using PBR
setup_kwargs['install_requires'] = install_requirements
# add setup.cfg information back from metadata
try:
from setuptools.config import read_configuration
config = read_configuration('%s/setup.cfg' % here)
metadata = config['metadata']
metadata['summary'] = metadata.get('summary', metadata['description'].split('\n')[0])
if setup_kwargs.pop('pbr', False) is not True:
setup_kwargs.update(metadata)
# explicitly compile a master list of install requirements - workaround for bug with PBR & bdist_wheel
setup_kwargs['install_requires'] = list(set(list(setup_kwargs.get('install_requires',
config.get('options', {})
.get('install_requires', []))) +
install_requirements))
except ImportError:
metadata = {}
finally:
readme_filename = '%s/%s' % (here, parser['metadata']['description-file'].strip())
with open(readme_filename) as f_desc:
long_description = f_desc.read()
setup_kwargs['long_description'] = long_description
# check whether we are using Markdown instead of Restructured Text and update setup accordingly
if readme_filename.lower().endswith('.md'):
setup_kwargs['long_description_content_type'] = 'text/markdown'
# update with further information for sphinx
metadata.update(parser['metadata'])
if __name__ == '__main__':
# actually perform setup here
setup(
setup_requires=['pbr', 'setuptools'],
packages=find_packages(),
entry_points={
'console_scripts': CONSOLE_SCRIPTS
},
tests_require=['pytest', 'coverage'],
include_package_data=True,
**setup_kwargs
)