-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
107 lines (88 loc) · 3.69 KB
/
Copy pathsetup.py
File metadata and controls
107 lines (88 loc) · 3.69 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
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
# ----------------------------------------------------------------------------
# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
#
# This file is part of Deepchecks.
# Deepchecks is distributed under the terms of the GNU Affero General
# Public License (version 3 or later).
# You should have received a copy of the GNU Affero General Public License
# along with Deepchecks. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------
import os
import pathlib
import re
import typing as t
import setuptools
SETUP_MODULE = pathlib.Path(__file__).absolute()
ROOTDIR = SETUP_MODULE.parent
VERSION_FILE = ROOTDIR / "VERSION"
SEMANTIC_VERSIONING_RE = re.compile(
r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)"
r"(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
r"(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))"
r"?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
)
PYTHON_VERSIONING_RE = re.compile(
r"^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*"
r"((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?"
r"(\.dev(0|[1-9][0-9]*))?$"
)
def is_correct_version_string(value: str) -> bool:
match = PYTHON_VERSIONING_RE.match(value)
return value == "dev" or match is not None
def get_version_string() -> str:
if not (VERSION_FILE.exists() and VERSION_FILE.is_file()):
raise RuntimeError(
"Version file does not exist! "
f"(filepath: {str(VERSION_FILE)})")
else:
version = VERSION_FILE.open("r").readline()
if not is_correct_version_string(version):
raise RuntimeError(
"Incorrect version string! "
f"(filepath: {str(VERSION_FILE)})"
)
return version
def read_requirements_file(path: pathlib.Path) -> t.Tuple[t.List[str], t.List[str]]:
if not (path.exists() and path.is_file()):
raise RuntimeError(f'Did not find requirements file - {path.name}')
# github_user = os.environ.get("GITHUB_USER")
github_token = os.environ.get("GITHUB_TOKEN")
deepchecks_ci_token = os.environ.get("DEEPCHECKS_CI_TOKEN")
dependencies = []
dependencies_links = []
for line in path.open("r").readlines():
if "-f" in line or "--find-links" in line:
dependencies_links.append(
line
.replace("-f", "")
.replace("--find-links", "")
.strip()
)
else:
if "${GITHUB_TOKEN}" in line:
if not github_token:
raise RuntimeError("Cannot provide github credentials")
else:
line = line.replace("${GITHUB_TOKEN}", github_token)
if "${DEEPCHECKS_CI_TOKEN}" in line and not line.startswith('#'):
if not deepchecks_ci_token:
raise RuntimeError("Cannot provide DEEPCHECKS_CI_TOKEN")
else:
line = line.replace("${DEEPCHECKS_CI_TOKEN}", deepchecks_ci_token)
dependencies.append(line)
return dependencies, dependencies_links
# ===============================================================
version = get_version_string()
install_requires, dependency_links = read_requirements_file(ROOTDIR / 'requirements.txt')
setuptools.setup(
name="deepchecks-monitoring",
version=version,
author="Deepchecks",
author_email="",
description="",
packages=setuptools.find_packages(where=".", include=["deepchecks_monitoring", "deepchecks_monitoring.*"]),
python_requires='>=3.8',
install_requires=install_requires,
dependency_links=dependency_links,
package_data={'deepchecks_monitoring.migrations': ['script.py.mako']},
)