## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%bcond_without check

Name:           maturin
Version:        1.1.0
Release:        %autorelease
Summary:        Build and publish Rust crates as Python packages
#SourceLicense:  MIT OR Apache-2.0

%global pypi_version %(echo %{version} | tr -d "~")

# (Apache-2.0 OR MIT) AND BSD-3-Clause
# (MIT OR Apache-2.0) AND Unicode-DFS-2016
# 0BSD
# 0BSD OR MIT OR Apache-2.0
# Apache-2.0
# Apache-2.0 OR BSD-2-Clause
# Apache-2.0 OR BSL-1.0
# Apache-2.0 OR MIT
# Apache-2.0 WITH LLVM-exception
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# CC0-1.0 OR MIT-0 OR Apache-2.0
# MIT
# MIT OR Apache-2.0
# MIT OR Apache-2.0 OR Zlib
# MIT OR Zlib OR Apache-2.0
# MPL-2.0
# Unlicense OR MIT
# Zlib OR Apache-2.0 OR MIT
License:        0BSD AND Apache-2.0 AND Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND MIT AND MPL-2.0 AND Unicode-DFS-2016 AND (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0 OR BSD-2-Clause) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (CC0-1.0 OR MIT-0 OR Apache-2.0) AND (MIT OR Apache-2.0 OR Zlib) AND (Unlicense OR MIT)
# LICENSE.dependencies contains a full license breakdown

URL:            https://github.com/PyO3/maturin
Source0:        %{pypi_source maturin %{pypi_version}}

# * disable features with missing dependencies:
#   - cli-completion (support for dynamic shell completions)
#   - cross (support for cross compiling with zig / xwin)
#   - upload (support for uploading wheels to PyPI)
# * drop unused test dependencies
Patch1:          0001-disable-unavailable-features-and-drop-unused-test-de.patch

# * drop incompatible arguments from setuptools_rust cargo invocations
Patch2:          0002-drop-incompatible-cargo-flags-from-setuptools_rust.patch

# * drop #!/usr/bin/env python3 shebang from maturin/__init__.py
Patch3:          0003-remove-shebang-from-non-executable-__init__.py-file.patch

# * bump minijinja dependency from 0.34 to 1.0:
#   https://github.com/PyO3/maturin/commit/7302439
Patch4:          0004-bump-minijinja-dependency-from-0.34-to-1.0.patch

BuildRequires:  rust-packaging >= 23
BuildRequires:  python3.11-devel
BuildRequires:  pyproject-rpm-macros
BuildRequires:  python3.11-devel
BuildRequires:  python3.11dist(pip) >= 19
BuildRequires:  python3.11dist(packaging)
BuildRequires:  python3.11-setuptools-rust

%py_provides python3.11-maturin

%description
Build and publish crates with pyo3, rust-cpython and cffi bindings as
well as rust binaries as python packages.

%prep
%autosetup -n maturin-%{pypi_version} -p1
%cargo_prep

#generate_buildrequires
#pyproject_buildrequires
%cargo_generate_buildrequires

%build
export RUSTFLAGS="%{build_rustflags}"
%pyproject_wheel
%cargo_license_summary
%{cargo_license} > LICENSE.dependencies

%install
%pyproject_install
%pyproject_save_files maturin

%if %{with check}
%check
# * skip tests for which fixtures are not included in published sources
%cargo_test -- -- --skip build_options::test::test_find_bridge --skip metadata::test::test_implicit_readme --skip metadata::test::test_merge_metadata_from_pyproject --skip pyproject_toml::tests::test_warn_missing_maturin_version
%endif

%files -f %{pyproject_files}
%license license-apache
%license license-mit
%license LICENSE.dependencies
%doc README.md
%doc Changelog.md
%{_bindir}/maturin

%changelog
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sat Jun 24 2023 Python Maint <python-maint@redhat.com> - 1.1.0-2
- Rebuilt for Python 3.12

* Sat Jun 24 2023 Fabio Valentini <decathorpe@gmail.com> - 1.1.0-1
- Update to version 1.1.0; Fixes RHBZ#2214007

* Wed Jun 14 2023 Python Maint <python-maint@redhat.com> - 1.0.1-3
- Rebuilt for Python 3.12

* Wed Jun 07 2023 Fabio Valentini <decathorpe@gmail.com> - 1.0.1-2
- Enable log and scaffolding features

* Mon May 29 2023 Fabio Valentini <decathorpe@gmail.com> - 1.0.1-1
- Update to version 1.0.1; Fixes RHBZ#2210549

* Tue May 23 2023 Fabio Valentini <decathorpe@gmail.com> - 1.0.0-1
- Update to version 1.0.0

* Tue May 23 2023 Fabio Valentini <decathorpe@gmail.com> - 1.0.0~b9-1
- Update to version 1.0.0b9

* Thu May 18 2023 Fabio Valentini <decathorpe@gmail.com> - 1.0.0~b7-1
- Initial import (#2187698)
