-
Notifications
You must be signed in to change notification settings - Fork 13
/
setup.py
146 lines (123 loc) · 4.33 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
import glob
import os
import shutil
import sys
from pathlib import Path
from setuptools import setup, find_packages, Command
HERE = Path(os.path.dirname(__file__)).absolute()
# get __version__ from gutenTAG/_version.py
with open(HERE / "gutenTAG" / "_version.py") as f:
exec(f.read())
VERSION: str = __version__ # noqa
README = (HERE / "README.md").read_text(encoding="UTF-8")
DOC_NAME = "GutenTAG"
PYTHON_NAME = "gutenTAG"
with open(HERE / "requirements.txt") as fh:
REQUIRED = fh.read().splitlines()
class PyTestCommand(Command):
description = f"run PyTest for {DOC_NAME}"
user_options = []
def initialize_options(self) -> None:
pass
def finalize_options(self) -> None:
pass
def run(self) -> None:
import pytest
from pytest import ExitCode
exit_code = pytest.main(
[
"--cov-report=term",
"--cov-report=xml:coverage.xml",
f"--cov={PYTHON_NAME}",
"tests",
]
)
if exit_code == ExitCode.TESTS_FAILED:
raise ValueError("Tests failed!")
elif exit_code == ExitCode.INTERRUPTED:
raise ValueError("pytest was interrupted!")
elif exit_code == ExitCode.INTERNAL_ERROR:
raise ValueError("pytest internal error!")
elif exit_code == ExitCode.USAGE_ERROR:
raise ValueError("Pytest was not correctly used!")
elif exit_code == ExitCode.NO_TESTS_COLLECTED:
raise ValueError("No tests found!")
# else: everything is fine
class MyPyCheckCommand(Command):
description = f"run MyPy for {DOC_NAME}; performs static type checking"
user_options = []
def initialize_options(self) -> None:
pass
def finalize_options(self) -> None:
pass
def run(self) -> None:
from mypy.main import main as mypy
args = ["--pretty", PYTHON_NAME, "tests"]
mypy(None, stdout=sys.stdout, stderr=sys.stderr, args=args)
class CleanCommand(Command):
description = "Remove build artifacts from the source tree"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
files = [".coverage*", "coverage.xml"]
dirs = [
"build",
"dist",
"*.egg-info",
"**/__pycache__",
".mypy_cache",
".pytest_cache",
"**/.ipynb_checkpoints",
]
for d in dirs:
for filename in glob.glob(d):
shutil.rmtree(filename, ignore_errors=True)
for f in files:
for filename in glob.glob(f):
try:
os.remove(filename)
except OSError:
pass
if __name__ == "__main__":
setup(
name=f"timeeval-{PYTHON_NAME}",
version=VERSION,
description="A good Timeseries Anomaly Generator.",
long_description=README,
long_description_content_type="text/markdown",
author="Phillip Wenig and Sebastian Schmidl",
author_email="[email protected]",
url="https://github.com/TimeEval/gutentag",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
"Typing :: Typed",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
],
packages=find_packages(exclude=("tests", "tests.*")),
package_data={"gutenTAG": ["py.typed", "config/schema/*"]},
install_requires=REQUIRED,
python_requires=">=3.7",
test_suite="tests",
cmdclass={
"test": PyTestCommand,
"typecheck": MyPyCheckCommand,
"clean": CleanCommand,
},
zip_safe=False,
# provides="gutenTAG",
entry_points={"console_scripts": ["gutenTAG=gutenTAG.__main__:cli"]},
)