/
setup.py
159 lines (139 loc) · 4.96 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# coding=utf-8
# from distutils.core import setup
import os
import re
from setuptools import setup
import sys
import json
# Old style (not recommended) check to prevent setup.py from being used on old pythons.
# Current recommended practice is to include supported pythons in the
# classifiers kwarg even though there is no automated enforcement.
if sys.version_info < (2, 6):
print('FullMonty requires python 2.6 or newer')
exit(-1)
#: str: Regular expression for parsing __version__ line in the packages __init__.py file.
VERSION_REGEX = r'__version__\s*=\s*[\'\"](\S+)[\'\"]'
# noinspection PyArgumentEqualDefault
def get_project_version():
"""
Get the version from __init__.py with a line: /^__version__\s*=\s*(\S+)/
If it doesn't exist try to load it from the VERSION.txt file.
If still no joy, then return '0.0.0'
:returns: the version string
:rtype: str
"""
# trying __init__.py first
try:
file_name = os.path.join(os.getcwd(), 'fullmonty', '__init__.py')
# noinspection PyBroadException
try:
# python3
# noinspection PyArgumentList
with open(file_name, 'r', encoding='utf-8') as inFile:
for line in inFile.readlines():
match = re.match(VERSION_REGEX, line)
if match:
return match.group(1)
except:
# python2
with open(file_name, 'r') as inFile:
for line in inFile.readlines():
match = re.match(VERSION_REGEX, line)
if match:
return match.group(1)
except IOError:
pass
# no joy, so try getting the version from a VERSION.txt file.
# try:
# file_name = os.path.join(os.getcwd(), 'cr', 'VERSION.txt')
# with open(file_name, 'r') as inFile:
# return inFile.read().strip()
# except IOError:
# pass
# no joy again, so return default
return '0.0.0'
#: List[str]: The list of the package names for runtime dependencies
required_imports = [
'six',
'pycrypto',
'pexpect',
]
print("Python (%s)" % sys.version)
# libraries that have been moved into python are added to the list of runtime
# dependencies by python version.
if sys.version_info < (3, 1):
required_imports.extend([
'ordereddict', # new in py31
'decorator',
])
if sys.version_info < (3, 2):
required_imports.extend([
"argparse", # new in py32
"configparser", # back port from py32
])
if sys.version_info < (3, 5):
required_imports.extend([
# "scandir", # new in py35
])
#: str: the CLI templates support two descriptions, one brief and one long.
long_description = ""
# here we set the long_description to the contents of the README.rst file.
# noinspection PyBroadException
try:
# noinspection PyBroadException
try:
long_description = open('README.rst').read()
except:
# noinspection PyArgumentList
long_description = open('README.rst', encoding='utf-8').read()
except:
pass
kwargs = {}
if os.path.isfile('setup.json'):
try:
with open('setup.json') as data_file:
kwargs = json.load(data_file)
except Exception as ex:
print("Unable to load setup.json - %s" % str(ex))
default_kwargs = {
'name': 'FullMonty',
'version': get_project_version(),
'author': 'Roy Wright',
'author_email': 'roy@wright.org',
'url': 'https://github.com/royw/fullmonty',
'packages': ['fullmonty'],
'package_dir': {'': '.'},
'package_data': {'fullmonty': ['*.txt', '*.js', '*.html', '*.css'],
'tests': ['*'],
'': ['*.rst', '*.txt', '*.rc', '*.in']},
'license': 'docs/license.rst',
'description': 'Eclectic library for applications.',
'long_description': long_description,
# use keywords relevant to the application
'keywords': [],
# use classifiers from: https://pypi.python.org/pypi?%3Aaction=list_classifiers
'classifiers': [
# 'Development Status :: 1 - Planning',
# 'Development Status :: 2 - Pre-Alpha',
# 'Development Status :: 3 - Alpha',
# 'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
# 'Development Status :: 6 - Mature',
# 'Development Status :: 7 - Inactive',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
# 'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development',
],
'install_requires': required_imports,
'entry_points': {
'console_scripts': ['fullmonty = fullmonty.fullmonty_main:main']
}
}
default_kwargs.update(kwargs)
setup(**default_kwargs)