Skip to content

Commit

Permalink
Fix version definition in setuptools (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqwang authored Feb 19, 2022
1 parent a54a0dd commit 811c759
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
from setuptools import setup, find_packages

PATH_ROOT = Path(__file__).parent.resolve()
VERSION = "0.6.0a0"

PACKAGE_NAME = "yolort"
version = "0.6.0a0"
sha = "Unknown"
package_name = "yolort"

try:
sha = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=PATH_ROOT).decode("ascii").strip()
except Exception:
pass

if os.getenv("BUILD_VERSION"):
version_yolort = os.getenv("BUILD_VERSION")
version = os.getenv("BUILD_VERSION")
elif sha != "Unknown":
version_yolort = f"{VERSION}+{sha[:7]}"
version += "+" + sha[:7]


def write_version_file():
version_path = PATH_ROOT / PACKAGE_NAME / "version.py"
version_path = PATH_ROOT / package_name / "version.py"
with open(version_path, "w") as f:
f.write(f"__version__ = '{version_yolort}'\n")
f.write(f"__version__ = '{version}'\n")
f.write(f"git_version = {repr(sha)}\n")
f.write("from torchvision.extension import _check_cuda_version\n")
f.write("if _check_cuda_version() > 0:\n")
Expand All @@ -44,7 +44,7 @@ def get_long_description():
# Get the long description from the README file
description = (PATH_ROOT / "README.md").read_text(encoding="utf-8")
# replace relative repository path to absolute link to the release
static_url = f"https://raw.githubusercontent.com/zhiqwang/yolov5-rt-stack/v{VERSION}"
static_url = f"https://raw.githubusercontent.com/zhiqwang/yolov5-rt-stack/v{version}"
description = description.replace("docs/source/_static/", f"{static_url}/docs/source/_static/")
description = description.replace("notebooks/assets/", f"{static_url}/notebooks/assets/")
description = description.replace("_graph_visualize.svg", "_graph_visualize.png")
Expand All @@ -66,13 +66,13 @@ def load_requirements(path_dir=PATH_ROOT, file_name="requirements.txt", comment_


if __name__ == "__main__":
print(f"Building wheel {PACKAGE_NAME}-{version_yolort}")
print(f"Building wheel {package_name}-{version}")

write_version_file()

setup(
name=PACKAGE_NAME,
version=version_yolort,
name=package_name,
version=version,
description="yolort is a runtime stack for object detection on specialized accelerators.",
author="Zhiqiang Wang",
author_email="[email protected]",
Expand Down

0 comments on commit 811c759

Please sign in to comment.