-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.py
More file actions
40 lines (30 loc) · 1.16 KB
/
Copy pathsetup.py
File metadata and controls
40 lines (30 loc) · 1.16 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re
from setuptools import setup
from setuptools_scm import get_version
GITHUB_URL = "https://github.com/awslabs/aurora-dsql-orms"
SUBDIR = "python/django"
version = get_version()
# Use default branch for dev versions, tag for releases.
if "dev" in version:
ref = "version-0"
else:
ref = f"v{version}"
with open("README.md", encoding="utf-8") as readme:
readme_content = readme.read()
def convert_relative_link(match):
link_text = match.group(1)
old_url = match.group(2)
if old_url.startswith(("./", "../")):
raise ValueError(f"Relative links starting with './' or '../' are not allowed: {old_url}")
new_url = f"{GITHUB_URL}/blob/{ref}/{SUBDIR}/{old_url}"
print(f"Converting: {old_url} -> {new_url}")
return f"[{link_text}]({new_url})"
# Links on PyPI require absolute URLs. Replace relative URLs with absolute ones.
long_description = re.sub(
r"\[([^]]+)]\(((?!https?:)[^)]+)\)",
convert_relative_link,
readme_content,
)
setup(long_description=long_description, long_description_content_type="text/markdown")