Skip to content

Commit 77ef131

Browse files
Add more URLs to package (#1156)
Sorry to add "complex logic in setup.py". Though it's a development feature closes #1155 I'm specifying `url` since it's not allowed in pyproject.toml: pypa/packaging-problems#606 --------- Co-authored-by: Justin Chu <[email protected]>
1 parent 00ea75e commit 77ef131

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ name = "onnxscript"
77
dynamic = ["version"]
88
description = "Naturally author ONNX functions and models using a subset of Python"
99
authors = [{ name = "Microsoft Corporation", email = "[email protected]" }]
10-
urls = { "Repository" = "https://github.com/microsoft/onnxscript" }
1110
readme = "README.md"
1211
requires-python = ">=3.8"
1312
license = { file = "LICENSE" }

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import datetime
88
import os
99
import pathlib
10+
import subprocess
1011

1112
import setuptools
1213

@@ -15,9 +16,20 @@
1516
VERSION_FILE = ROOT_DIR / "VERSION"
1617
version = VERSION_FILE.read_text().strip()
1718

19+
project_urls = {
20+
"Repository": "https://github.com/microsoft/onnxscript",
21+
}
1822
if os.environ.get("ONNX_SCRIPT_RELEASE") != "1":
1923
date = datetime.date.today().strftime("%Y%m%d")
2024
version = f"{version}.dev{date}"
2125

26+
commit_hash_cmd = subprocess.run(
27+
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=False
28+
)
29+
if commit_hash_cmd.returncode == 0:
30+
project_urls[
31+
"Commit"
32+
] = f"https://github.com/microsoft/onnxscript/tree/{commit_hash_cmd.stdout.decode('utf-8').strip()}"
33+
2234
# NOTE: Do not include other metadata in setup.py. Put it in pyproject.toml.
23-
setuptools.setup(version=version)
35+
setuptools.setup(version=version, project_urls=project_urls, url="https://onnxscript.ai/")

0 commit comments

Comments
 (0)