Skip to content

Commit

Permalink
Add more URLs to package (#1156)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
take-cheeze and justinchuby authored Nov 22, 2023
1 parent 00ea75e commit 77ef131
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ name = "onnxscript"
dynamic = ["version"]
description = "Naturally author ONNX functions and models using a subset of Python"
authors = [{ name = "Microsoft Corporation", email = "[email protected]" }]
urls = { "Repository" = "https://github.com/microsoft/onnxscript" }
readme = "README.md"
requires-python = ">=3.8"
license = { file = "LICENSE" }
Expand Down
14 changes: 13 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datetime
import os
import pathlib
import subprocess

import setuptools

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

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

commit_hash_cmd = subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=False
)
if commit_hash_cmd.returncode == 0:
project_urls[
"Commit"
] = f"https://github.com/microsoft/onnxscript/tree/{commit_hash_cmd.stdout.decode('utf-8').strip()}"

# NOTE: Do not include other metadata in setup.py. Put it in pyproject.toml.
setuptools.setup(version=version)
setuptools.setup(version=version, project_urls=project_urls, url="https://onnxscript.ai/")

0 comments on commit 77ef131

Please sign in to comment.