f4pga/setup: if git is available, append commit sha to version

Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
Unai Martinez-Corral 2022-08-02 01:38:57 +02:00 committed by Unai Martinez-Corral
parent d0dedab0c5
commit 865c1fda41
1 changed files with 10 additions and 1 deletions

View File

@ -19,6 +19,8 @@
from pathlib import Path from pathlib import Path
from typing import List from typing import List
from shutil import which
from subprocess import check_output
from setuptools import setup as setuptools_setup from setuptools import setup as setuptools_setup
@ -50,13 +52,20 @@ def get_requirements(file: Path) -> List[str]:
return requirements return requirements
version="0.0.0"
git = which('git')
if git is not None:
sha = check_output(['git', 'rev-parse', 'HEAD']).decode('utf8')
version += f'-{sha[0:8]}'
sf = "symbiflow" sf = "symbiflow"
shwrappers = "f4pga.wrappers.sh.__init__" shwrappers = "f4pga.wrappers.sh.__init__"
setuptools_setup( setuptools_setup(
name=packagePath.name, name=packagePath.name,
version="0.0.0", version=version,
license="Apache-2.0", license="Apache-2.0",
author="F4PGA Authors", author="F4PGA Authors",
description="F4PGA.", description="F4PGA.",