%global _empty_manifest_terminate_build 0
%global pypi_name vl-convert-python

Name:           python-%{pypi_name}
Version:        1.7.0
Release:        2
Summary:        Convert Vega-Lite chart specifications to SVG, PNG, or Vega.

License:        BSD-3-Clause
URL:            https://github.com/jonmmease/vl-convert
Source0:        %{url}/archive/v%{version}/%{pypi_name}-%{version}.tar.gz
# Source2 created with ./prepare_rusty_v6.sh v8-version
Source1:        cargo-vendor-cache
Source2:        cargo-librusty-v8-v0.105.1

BuildRequires:	rust-packaging
BuildRequires:	cmake
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-setuptools-rust
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
BuildRequires:	python3-hatchling
BuildRequires:  python3-maturin

%description
Convert Vega-Lite chart specifications to SVG, PNG, or Vega.


%package -n     python3-%{pypi_name}
Summary:        %{summary}

%description -n python3-%{pypi_name}
Convert Vega-Lite chart specifications to SVG, PNG, or Vega.


%prep
%autosetup -p1 -n vl-convert-%{version}
tar xzvf %{SOURCE1} -C .
tar xzvf %{SOURCE2} -C ./vendor/v8/
oldsum=$(sha256sum ./vendor/v8/build.rs)
oldv8=${oldsum%%%% *}
sed -i '/    env::var(\"RUSTY_V8_MIRROR\")/,1 d' ./vendor/v8/build.rs
sed -i "s#^  let base =.*#  let base = env\:\:current_dir().unwrap().into_os_string().into_string().unwrap();#g" ./vendor/v8/build.rs
newsum=$(sha256sum ./vendor/v8/build.rs)
newv8=${newsum%%%% *}
sed -i s#${oldv8}#${newv8}#g `grep ${oldv8} -rl ./vendor/v8/`
mkdir .cargo
cat >> .cargo/config.toml << EOF
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF


%build
cd vl-convert-python
%pyproject_build

%install
cd vl-convert-python
%pyproject_install

%files -n python3-%{pypi_name}
%doc README.md
%{python3_sitearch}/vl_convert
%{python3_sitearch}/vl_convert*.dist-info/

%changelog
* Thu Feb 13 2025 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 1.7.0-2
- Fix build error for compile rusty-v8 offline

* Wed Nov 13 2024 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 1.7.0-1
- Update version to 1.7.0
  Adds vl_convert.pyi type stub
  Fix build of macos intel wheels
  Handle non-positive text size and zero font width limit
  Added support for color emoji
  Support configurable renderer in html export
  Add online and offline html export support
  Add conversions to Vega scenegraph
  Set baseURL to support "data/movies.json" style URLs
  PDF support
  Add support for converting SVG images to PNG, JPEG, and PDF

* Tue Aug 27 2024 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 0.13.1-2
- Make cargo update for rust version upgrade

* Fri Sep 15 2023 Dongxing Wang <dxwangk@isoftstone.com> - 0.13.1-1
- Initial package