forked from alpha-xone/xbbg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
92 lines (77 loc) · 2.56 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
80
81
82
83
84
85
86
87
88
89
90
91
92
import pathlib
from os import path
from setuptools import setup, find_packages
# for pip >= 10
try:
from pip._internal.req import parse_requirements
# for pip <= 9.0.3
except ImportError:
from pip.req import parse_requirements
PACKAGE_ROOT = pathlib.Path(__file__).parent
def parse_version(package):
"""
Parse versions
"""
init_file = f'{PACKAGE_ROOT}/{package}/__init__.py'
with open(init_file, 'r', encoding='utf-8') as f:
for line in f.readlines():
if '__version__' in line:
return line.split('=')[1].strip()[1:-1]
return ''
def parse_markdown():
"""
Parse markdown as description
"""
readme_file = f'{PACKAGE_ROOT}/README.md'
if path.exists(readme_file):
with open(readme_file, 'r', encoding='utf-8') as f:
long_description = f.read()
return long_description
def parse_description(markdown=True):
"""
Parse the description in the README file
"""
if markdown: return parse_markdown()
try:
from pypandoc import convert
readme_file = f'{PACKAGE_ROOT}/docs/index.rst'
if not path.exists(readme_file):
raise ImportError
return convert(readme_file, 'rst')
except ImportError:
return parse_markdown()
if __name__ == '__main__':
setup(
name='xbbg',
version=parse_version('xbbg'),
description='Intuitive Bloomberg data API',
long_description=parse_description(),
long_description_content_type='text/markdown',
url='https://github.com/alpha-xone/xbbg',
author='Alpha x1',
author_email='[email protected]',
license='Apache',
classifiers=[
"License :: OSI Approved :: Apache Software License",
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
include_package_data=True,
package_data={
'yaml': ['xbbg/markets/*.yml']
},
install_requires=[
str(getattr(ir, 'req' if hasattr(ir, 'req') else 'requirement'))
for ir in parse_requirements(
f'{PACKAGE_ROOT}/requirements.txt', session='hack'
)
],
packages=find_packages(include=['xbbg', 'xbbg.*']),
dependency_links=[
'https://bloomberg.bintray.com/pip/simple',
],
)
print('\nBloomberg API')
print('^^^^^^^^^^^^^\n')
print('pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi')