-
Notifications
You must be signed in to change notification settings - Fork 68
/
setup.py
91 lines (77 loc) · 2.85 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
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
"""Setup instructions for the mlos_viz package."""
# pylint: disable=duplicate-code
import os
import re
from itertools import chain
from logging import warning
from setuptools import setup
PKG_NAME = "mlos_viz"
try:
ns: dict[str, str] = {}
with open(f"{PKG_NAME}/version.py", encoding="utf-8") as version_file:
exec(version_file.read(), ns) # pylint: disable=exec-used
VERSION = ns["VERSION"]
except OSError:
VERSION = "0.0.1-dev"
warning(f"version.py not found, using dummy VERSION={VERSION}")
try:
from setuptools_scm import get_version
version = get_version(root="..", relative_to=__file__, fallback_version=VERSION)
if version is not None:
VERSION = version
except ImportError:
warning("setuptools_scm not found, using version from version.py")
except LookupError as e:
warning(f"setuptools_scm failed to find git version, using version from version.py: {e}")
# A simple routine to read and adjust the README.md for this module into a format
# suitable for packaging.
# See Also: copy-source-tree-docs.sh
# Unfortunately we can't use that directly due to the way packaging happens inside a
# temp directory.
# Similarly, we can't use a utility script outside this module, so this code has to
# be duplicated for now.
def _get_long_desc_from_readme(base_url: str) -> dict:
pkg_dir = os.path.dirname(__file__)
readme_path = os.path.join(pkg_dir, "README.md")
if not os.path.isfile(readme_path):
return {
"long_description": "missing",
}
jsonc_re = re.compile(r"```jsonc")
link_re = re.compile(r"\]\(([^:#)]+)(#[a-zA-Z0-9_-]+)?\)")
with open(readme_path, encoding="utf-8") as readme_fh:
lines = readme_fh.readlines()
# Tweak the lexers for local expansion by pygments instead of github's.
lines = [link_re.sub(f"]({base_url}" + r"/\1\2)", line) for line in lines]
# Tweak source source code links.
lines = [jsonc_re.sub(r"```json", line) for line in lines]
return {
"long_description": "".join(lines),
"long_description_content_type": "text/markdown",
}
extra_requires: dict[str, list[str]] = {}
# construct special 'full' extra that adds requirements for all built-in
# backend integrations and additional extra features.
extra_requires["full"] = list(set(chain(*extra_requires.values())))
extra_requires["full-tests"] = extra_requires["full"] + [
"pytest",
"pytest-forked",
"pytest-xdist",
"pytest-cov",
"pytest-local-badge",
]
setup(
version=VERSION,
install_requires=[
"mlos-bench==" + VERSION,
"dabl>=0.3.2",
"matplotlib",
"seaborn>=0.12.2",
],
extras_require=extra_requires,
**_get_long_desc_from_readme("https://github.com/microsoft/MLOS/tree/main/mlos_viz"),
)