-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
69 lines (53 loc) · 1.64 KB
/
Copy pathsetup.py
File metadata and controls
69 lines (53 loc) · 1.64 KB
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
import ast
import os
import re
import subprocess
from setuptools import Command, setup
PACKAGE_NAME = 'python_boilerplate'
with open(os.path.join(PACKAGE_NAME, '__init__.py')) as f:
match = re.search(r'__version__\s+=\s+(.*)', f.read())
version = str(ast.literal_eval(match.group(1)))
class SimpleCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
class VetCommand(SimpleCommand):
def run(self):
subprocess.check_call(["mypy", PACKAGE_NAME])
subprocess.check_call(["flake8"])
class FmtCommand(SimpleCommand):
def run(self):
subprocess.call(["isort", "-y"])
subprocess.call(["autopep8", "-ri", PACKAGE_NAME, "tests", "setup.py"])
class DocCommand(SimpleCommand):
def run(self):
opt = "-f" if os.path.exists(os.path.join("docs", "conf.py")) else "-F"
subprocess.call(["sphinx-apidoc", opt, "-o", "docs", PACKAGE_NAME])
if os.name == 'nt':
subprocess.call([os.path.join("docs", "make.bat"), "html"]) # for Windows
else:
subprocess.call(["make", "-C", "docs", "html"])
setup(
# metadata
name=PACKAGE_NAME,
version=version,
# options
packages=[PACKAGE_NAME],
include_package_data=True,
zip_safe=False,
python_requires='>=3.4',
install_requires=[
'typing; python_version<"3.5"',
],
entry_points='''
[console_scripts]
{app}={pkg}.cli:main
'''.format(app=PACKAGE_NAME.replace('_', '-'), pkg=PACKAGE_NAME),
cmdclass={
"vet": VetCommand,
"fmt": FmtCommand,
"doc": DocCommand,
},
)