aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Sun <peng.sun@arm.com>2023-08-08 21:59:46 +0100
committerPeng Sun <peng.sun@arm.com>2023-08-14 10:10:23 +0100
commit48c123c3f4581eeadda73460f903ba5a4e2c043f (patch)
treeb3ab24f76847600544706988962fc5096980cf74
parent23fbf7004b47bbc338856cdd4fc042be12734a18 (diff)
downloadtosa_checker-48c123c3f4581eeadda73460f903ba5a4e2c043f.tar.gz
Replace relative links with absolute links to https://review.mlplatform.org in package description.
Change-Id: Id890542b76c383d868a40f2748184a8ee051ab82
-rw-r--r--setup.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/setup.py b/setup.py
index 6aadd48..7aaf5d1 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
import argparse
import git
import os
-import pathlib
+import re
import setuptools
import setuptools.command.build_ext
import shutil
@@ -164,11 +164,30 @@ class BazelBuildExtension(setuptools.command.build_ext.build_ext):
)
+def get_long_description(nightly):
+ # Read the contents of README.md file
+ this_directory = os.path.abspath(os.path.dirname(__file__))
+ with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
+ long_description = f.read()
+
+ if not nightly:
+ # Replace relative links to existing files with absolute links to https://review.mlplatform.org
+ url = f"https://review.mlplatform.org/plugins/gitiles/tosa/tosa_checker/+/refs/tags/{TOSA_CHECKER_VERSION}/"
+ # Find all markdown links that match the format: [text](link)
+ for match, link in re.findall(r"(\[.+?\]\((.+?)\))", long_description):
+ # If the link is a file that exists, replace it with the web link to the file instead
+ if os.path.exists(os.path.join(this_directory, link)):
+ url_link = re.sub(r"\((.+?)\)", rf"({url}{link})", match)
+ long_description = long_description.replace(match, url_link)
+
+ return long_description
+
+
setuptools.setup(
name="tosa-checker",
version=get_package_version(args.nightly),
description="Tool to check if a ML model is compatible with the TOSA specification",
- long_description=(pathlib.Path(__file__).parent / "README.md").read_text(),
+ long_description=get_long_description(args.nightly),
long_description_content_type="text/markdown",
author="Arm Limited",
url="https://git.mlplatform.org/tosa/tosa_checker.git/",