From 865c1fda41bb6445b327416812b9a0a863d920de Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Tue, 2 Aug 2022 01:38:57 +0200 Subject: [PATCH] f4pga/setup: if git is available, append commit sha to version Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/f4pga/setup.py b/f4pga/setup.py index 3fef988..a15a792 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -19,6 +19,8 @@ from pathlib import Path from typing import List +from shutil import which +from subprocess import check_output from setuptools import setup as setuptools_setup @@ -50,13 +52,20 @@ def get_requirements(file: Path) -> List[str]: 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" shwrappers = "f4pga.wrappers.sh.__init__" setuptools_setup( name=packagePath.name, - version="0.0.0", + version=version, license="Apache-2.0", author="F4PGA Authors", description="F4PGA.",