#
# spec file for package python-setuptools-rust
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define skip_python36 1
%define skip_python38 1
%define skip_python39 1
%define skip_python311 1


%global skip_python2 1
%{?sle15_python_module_pythons}
Name:           python-setuptools-rust
Version:        1.5.2
Release:        2.1
Summary:        Setuptools plugin for Rust extensions
License:        BSD-3-Clause
Group:          Development/Languages/Python
URL:            https://github.com/PyO3/setuptools-rust
Source:         https://files.pythonhosted.org/packages/source/s/setuptools-rust/setuptools-rust-%{version}.tar.gz
BuildRequires:  %{python_module base >= 3.7}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module pyparsing}
BuildRequires:  %{python_module semantic_version >= 2.8.2}
BuildRequires:  %{python_module setuptools >= 62.4}
BuildRequires:  %{python_module setuptools_scm >= 6.3.2}
BuildRequires:  %{python_module typing_extensions >= 3.7.4.3}
BuildRequires:  %{python_module wheel}
BuildRequires:  cargo
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  rust
Requires:       cargo
Requires:       python-semantic_version >= 2.8.2
Requires:       python-setuptools >= 62.4
Requires:       python-typing_extensions >= 3.7.4.3
Requires:       rust
BuildArch:      noarch
# SECTION test requirements
BuildRequires:  %{python_module pytest}
# /SECTION
%python_subpackages

%description
setuptools-rust is a plugin for setuptools to build Rust Python extensions
implemented with PyO3 or rust-cpython.

Compile and distribute Python extensions written in Rust as easily as if they
were written in C.

%prep
%setup -q -n setuptools-rust-%{version}

%build
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
export LANG=en_US.UTF-8
# network / crates.io access
%pytest tests/ -k "not test_get_lib_name_namespace_package"
pushd examples/hello-world
%{python_expand # See noxfile.py
# hello-world is the only example which does not need extra rust packages (via cargo_vendor)
export PYTHONPATH=%{buildroot}%{$python_sitelib}
$python -m pip install --no-build-isolation --target=$PWD/build/exampleinstall/ --no-deps --no-index .
$PWD/build/exampleinstall/bin/hello-world
}
popd

%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/setuptools_rust-%{version}*-info
%{python_sitelib}/setuptools_rust

%changelog
* Fri Apr 21 2023 Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
* Thu Apr 13 2023 Matej Cepl <mcepl@suse.com>
- Make calling of %%{sle15modernpython} optional.
* Mon Jan  2 2023 Dirk Müller <dmueller@suse.com>
- update to 1.5.2:
  * Fix regression in `dylib` build artifacts not being found since 1.5.0.
  * Fix regression in sdist missing examples and other supplementary files
    since 1.5.0. #291
  * Fix regression in `get_lib_name` crashing since 1.5.0. #280
  * Fix regression in `Binding.Exec` builds with multiple executables not
    finding built executables since 1.5.0. #283
  * Add support for extension modules built for wasm32-unknown-emscripten
    with Pyodide. #244
  * Locate cdylib artifacts by handling messages from cargo instead of
    searching target dir (fixes build on MSYS2). #267
  * No longer guess cross-compile environment using `HOST_GNU_TYPE` /
    `BUILD_GNU_TYPE` sysconfig variables. #269
  * Fix RustBin build without wheel. #273
  * Fix RustBin setuptools install. #275
* Wed Jul 20 2022 Ben Greiner <code@bnavigator.de>
- Fix requirements
  * Don't need sphinx
  * Needs rust and cargo
  * Don't need nox; can't use it in obs as it wants to install
    wheels.
- Fix tests:
  * Plain pytest test suite without is rudimentary
  * At least build the hello-world example
- Use PEP517
* Mon Jul 18 2022 Matej Cepl <mcepl@suse.com>
- Deduplicate files in python_sitelib.
* Sat Jul 16 2022 Arun Persaud <arun@gmx.de>
- specfile:
  * update setuptools requirement to 62.4
  * require pyparsing
  * be mor specific in %%files section
  * use pytest
- update to version 1.4.1:
  * Fixed
    + Fix crash when checking Rust version. #263
- changes from version 1.4.0:
  * Packaging
    + Increase minimum setuptools version to 62.4. #246
  * Added
    + Add cargo_manifest_args to support locked, frozen and offline
    builds. #234
    + Add RustBin for packaging binaries in scripts data
    directory. #248
  * Changed
    + Exec binding RustExtension with script=True is deprecated in
    favor of RustBin. #248
    + Errors while calling cargo metadata are now reported back to the
    user #254
    + quiet option will now suppress output of cargo metadata. #256
    + setuptools-rust will now match cargo behavior of not setting
  - -target when the selected target is the rust host. #258
    + Deprecate native option of RustExtension. #258
  * Fixed
    + If the sysconfig for BLDSHARED has no flags, setuptools-rust
    won't crash anymore. #241
* Sun May 15 2022 Dirk Müller <dmueller@suse.com>
- update to 1.3.0:
  * Increase minimum `setuptools` version to 58.
  * Fix crash when `python-distutils-extra` linux package is installed.
  * Fix sdist built with vendored dependencies on Windows having incorrect cargo config.
  * Drop support for Python 3.6.
* Fri Feb  4 2022 Dirk Müller <dmueller@suse.com>
- update to 1.1.2:
  * Removed dependency on `tomli` to simplify installation
  * Improve error messages on invalid inputs to `rust_extensions` keyword
  * Fix regression from `setuptools-rust` 1.1.0 which broke builds for the
    `x86_64-unknown-linux-musl` targeta
  * Fix `--target` command line option being unable to take a value
  * Fix regression from `setuptools-rust` 1.1.0 which incorrectly converted
    library extension suffixes to the "abi3" suffix when `py_limited_api` was
    unspecified Add support for cross-compiling using
  * [`cross`](https://github.com/rust-embedded/cross)
  * Fix incompatibility with Python 3.6.0 using default values for NamedTuple classes
  * Stop forcing the `msvc` Rust toolchain for Windows environments using the
    `gnu` toolchain
* Mon Jan 10 2022 Dirk Müller <dmueller@suse.com>
- skip building for python 2.x, as the setuptools we have is no
  longer compatible with it
* Sat Nov 27 2021 Dirk Müller <dmueller@suse.com>
- Initial package (1.0.0)