%global pkgvers 0
%global scdate0 20241209
%global schash0 04f87df191b688b06dc33c949cbadd2e96878583
%global branch0 master
%global source0 https://github.com/YosysHQ/apicula.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Name:           prjapicula
Version:        0.15
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        GOWIN FPGA bitstream tools
License:        MIT
BuildArch:      noarch

URL:            https://github.com/SymbiFlow/apicula

Source1:        %{name}-db.tar.xz

BuildRequires:  git python3-devel python3-setuptools

%global _python_dist_allow_version_zero 1

%description
Project apicula enables a fully open-source flow for Gowin FPGA parts.

%package        devel
Summary:        Development files for Project %{name}

%description    devel
Development files to build packages using project %{name}


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller
%setup -D -T -c -n %{name} -a 1


%build
sed -i '/setuptools_scm/d' setup.py
%py3_build


%install
%py3_install
install -Dpm644 -t %{buildroot}%{python3_sitelib}/apycula/ %{name}-db/*.pickle
find %{buildroot}/%{python3_sitelib} -name '*.py' -exec sed -i '/from __future__ import annotations/d' {} +


%files
%doc readme.md
%doc doc
%{_bindir}/*
%{python3_sitelib}/*

%files devel
%doc legacy
%doc examples


%changelog
* Sat Feb 06 2021 Cristian Balint <cristian.balint@gmail.com>
- git upstream releases