-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
51 lines (44 loc) · 1.93 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
#
# --------------------------------------------------------------------------
# Licensed under the MIT License. See LICENSE file in the project root for
# license information.
# Copyright (c) Microsoft Corporation.
# --------------------------------------------------------------------------
#
"""Setup instructions for the vasim package."""
import os
import re
from setuptools import setup
# Adjust this version number to match the current release.
# See maintainers notes in CONTRIBUTING.md for details.
# Note: the "-dev" suffix is used to indicate a development version for local
# testing and should remain (it will be stripped off for the release version).
VERSION = "0.1.4-dev"
# A simple routine to read and adjust the README.md for this module into a format
# suitable for packaging.
# See Also: https://github.com/microsoft/MLOS/tree/main/mlos_core/setup.py
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, mode="r", encoding="utf-8") as readme_fh:
lines = readme_fh.readlines()
# Tweak source source code links.
lines = [jsonc_re.sub(r"```json", line) for line in lines]
# 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]
return {
"long_description": "".join(lines),
"long_description_content_type": "text/markdown",
}
# version_tag = "main"
version_tag = f"v{VERSION.replace('-dev', '')}" # pylint: disable=invalid-name
setup(
version=VERSION,
**_get_long_desc_from_readme(f"https://github.com/microsoft/vasim/tree/{version_tag}/"),
)