Skip to content

Commit

Permalink
GNNE-1909 remove date in version (#1038)
Browse files Browse the repository at this point in the history
* remove date in version

* remove date in new tag

* fix windows

* set env for cibuildwheel

* Apply code-format changes

* test git

* use gitpython to confirm tag with data

* add build-backend and requires

* fix branch without tag

---------

Co-authored-by: yanghaoqi <yanghaoqi_intern@canaan-creative.com>
Co-authored-by: curioyang <curioyang@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 10, 2023
1 parent ec47028 commit 8d1b273
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ dependencies = ["numpy"]
homepage = "https://github.com/kendryte/nncase"

[build-system]
requires = ["setuptools>=42", "wheel", "conan<=1.59", "ninja"]
requires = ["setuptools>=42", "wheel", "conan<=1.59", "ninja", "gitpython"]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
build = ["cp37*", "cp38*", "cp39*", "cp310*"]
Expand Down
2 changes: 1 addition & 1 deletion requirements.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pytest-xdist
pyyaml
pythonnet==3.0.1
clr_loader==0.2.4
toml==0.10.2
toml==0.10.2
14 changes: 13 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import io
import re
import time

import subprocess
from git.repo import Repo
# See ref: https://stackoverflow.com/a/51575996


Expand Down Expand Up @@ -277,8 +278,19 @@ def find_version():
version_prefix = re.findall(r"NNCASE_VERSION \"(.+)\"", version_file)

if version_prefix:
repo_path = os.getcwd()
repo = Repo(repo_path)
if repo.tags:
latest_commit = subprocess.check_output(
['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
tagged_commit = subprocess.check_output(
['git', 'rev-list', '-n', '1', repo.tags[-1].name]).decode('utf-8').strip()
if latest_commit == tagged_commit:
return version_prefix[0]

version_suffix = time.strftime("%Y%m%d", time.localtime())
return version_prefix[0] + "." + version_suffix

raise RuntimeError("Unable to find version string.")


Expand Down

0 comments on commit 8d1b273

Please sign in to comment.