-
Notifications
You must be signed in to change notification settings - Fork 121
/
setup.py
119 lines (104 loc) · 3.83 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
import logging
import os
import sys
try:
from setuptools import setup
except ImportError:
print("WARNING: setuptools not installed. Will try using distutils instead..")
from distutils.core import setup
def launch_http_server(directory):
assert os.path.isdir(directory)
try:
try:
from SimpleHTTPServer import SimpleHTTPRequestHandler
except ImportError:
from http.server import SimpleHTTPRequestHandler
try:
import SocketServer
except ImportError:
import socketserver as SocketServer
import socket
for port in [80] + list(range(8000, 8100)):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('localhost', port))
s.close()
except socket.error as e:
logging.debug("Can't use port %d: %s" % (port, e.strerror))
continue
print("HTML coverage report now available at http://{}{}".format(
socket.gethostname(), (":%s" % port) if port != 80 else ""))
os.chdir(directory)
SocketServer.TCPServer(("", port),
SimpleHTTPRequestHandler).serve_forever()
else:
logging.debug("All network port. ")
except Exception as e:
logging.error("ERROR: while starting an HTTP server to serve "
"the coverage report: %s" % e)
command = sys.argv[-1]
if command == 'publish':
os.system('rm -rf dist')
os.system('python3 setup.py sdist')
os.system('python3 setup.py bdist_wheel')
os.system('twine check dist/*') # check for formatting or other issues that would cause twine upload to error out
os.system('twine upload dist/*whl dist/*gz')
sys.exit()
elif command == "coverage":
try:
import coverage
except:
sys.exit("coverage.py not installed (pip install --user coverage)")
setup_py_path = os.path.abspath(__file__)
os.system('coverage run --source=configargparse ' + setup_py_path +' test')
os.system('coverage report')
os.system('coverage html')
print("Done computing coverage")
launch_http_server(directory="htmlcov")
sys.exit()
long_description = ''
if command not in ['test', 'coverage']:
long_description = open('README.rst').read()
install_requires = []
tests_require = [
'mock',
'PyYAML',
'pytest',
]
setup(
name='ConfigArgParse',
version="1.7",
description='A drop-in replacement for argparse that allows options to '
'also be set via config files and/or environment variables.',
long_description=long_description,
url='https://github.com/bw2/ConfigArgParse',
py_modules=['configargparse'],
include_package_data=True,
license="MIT",
keywords='options, argparse, ConfigArgParse, config, environment variables, '
'envvars, ENV, environment, optparse, YAML, INI',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
test_suite='tests',
python_requires='>=3.5',
install_requires=install_requires,
tests_require=tests_require,
extras_require = {
'yaml': ["PyYAML"],
'test': tests_require,
}
)