f4pga/setup: do not fail when installing tarballs having git available

This commit is contained in:
Unai Martinez-Corral 2022-08-02 02:17:53 +02:00
parent 865c1fda41
commit c6a4e2fd08
1 changed files with 9 additions and 4 deletions

View File

@ -20,7 +20,7 @@
from pathlib import Path
from typing import List
from shutil import which
from subprocess import check_output
from subprocess import run
from setuptools import setup as setuptools_setup
@ -52,12 +52,17 @@ def get_requirements(file: Path) -> List[str]:
return requirements
version="0.0.0"
semver = "0.0.0"
version = None
git = which('git')
if git is not None:
sha = check_output(['git', 'rev-parse', 'HEAD']).decode('utf8')
version += f'-{sha[0:8]}'
proc = run(['git', 'rev-parse', 'HEAD'], capture_output=True)
if proc.returncode == 0:
version = f'{semver}-{proc.stdout.decode("utf8")[0:8]}'
if version is None:
version = semver
sf = "symbiflow"
shwrappers = "f4pga.wrappers.sh.__init__"