%global commit0 cd79db632c9a506ad61ae72bfad5875341ca56b8
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})

Name:           nototools
Version:        0.2.17
Release:        1
Summary:        Noto fonts support tools and scripts plus web site generation
License:        ASL 2.0
URL:            https://github.com/googlei18n/nototools
Source0:        https://github.com/googlei18n/nototools/archive/%{commit0}/nototools-%{shortcommit0}.tar.gz
BuildArch:      noarch
BuildRequires:  python3-devel python-setuptools python3-wheel python3-setuptools_scm
Requires:       python3-nototools = %{version}-%{release} python3-pillow

%description
The tools package contains python scripts, \
these scripts used to maintain the Noto Fonts project.

%package        help
Summary:        document for nototools
%description    help
Help document for nototools

%package        -n python3-nototools
Summary:        Noto tools for python 3
Requires:       python3dist(fonttools)
BuildRequires:  python3dist(fonttools)

%description    -n python3-nototools
The tools package contains python3 scripts.

%prep
%autosetup -c -p0

# fix module 'nototools.notoconfig' has no attribute 'values'
sed -i 's/notoconfig.values/notoconfig._values/g' */nototools/autofix_for_release.py

rm -rf nototools-%{commit0}/third_party/{cldr,dspl,fontcrunch,ohchr,spiro,udhr,unicode}
mv %{name}-%{commit0} python3
cp python3/*.md python3/LICENSE .

%build
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
cd python3
%py3_build
cd ..

%install
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
cd python3
%py3_install
for lib in %{buildroot}%{python3_sitelib}/nototools/*.py; do
 sed '1{\@^#!/usr/bin/env python@d}' $lib > $lib.new &&
 touch -r $lib $lib.new &&
 mv $lib.new $lib
done
cd ..

%files
%license LICENSE
%{_bindir}/*.py
%{_bindir}/notocoverage
%{_bindir}/notodiff

%files help
%doc CONTRIBUTING.md README.md

%files -n python3-nototools
%{python3_sitelib}/nototools
%{python3_sitelib}/notofonttools-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/third_party


%changelog
* Thu Sep 15 2022 lutcunpeng <lutkunpeng@163.com> - 0.2.17-1
- DESC: update to 0.2.17

* Wed Apr 6 2022 caodongxia <caodongxia@h-partners.com> - 0-3
- fix build error caused by python3.10 wildcard

* Wed Oct 21 2020 wangxiao <wangxiao65@huawei.com> - 0-2
- drop python2 subpackage

* Thu Nov 21 2019 zhujunhao <zhujunhao5@huawei.com> - 0-1.20190712.git9c4375f
- Initial package
