## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    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

# Tests crash when being run by pytest-xdist
%bcond_with xdist

%global srcname SQLAlchemy
%global canonicalname %{py_dist_name %{srcname}}

%global python_pkg_extras \
    asyncio \
    mssql_pymssql \
    mssql_pyodbc \
    mysql \
    postgresql \
    postgresql_pg8000 \
    postgresql_asyncpg \
    pymysql \
    aiomysql \
    aiosqlite

Name:           python-sqlalchemy1.4
Version:        1.4.54
# cope with pre-release versions containing tildes
%global srcversion %{lua: srcversion, num = rpm.expand("%{version}"):gsub("~", ""); print(srcversion);}
Release:        %autorelease
Summary:        Modular and flexible ORM library for Python

License:        MIT
URL:            https://www.sqlalchemy.org/
Source0:        %{pypi_source %{canonicalname} %{srcversion}}

BuildRequires:  coreutils
BuildRequires:  findutils
BuildRequires:  gcc
BuildRequires:  python3-devel >= 3.6
# The dependencies needed for testing don’t get auto-generated.
BuildRequires:  python3dist(pytest)
%if %{with xdist}
BuildRequires:  python3dist(pytest-xdist)
%endif

%description
SQLAlchemy is an Object Relational Mapper (ORM) that provides a flexible,
high-level interface to SQL databases.  Database and domain concepts are
decoupled, allowing both sides maximum flexibility and power. SQLAlchemy
provides a powerful mapping layer that can work as automatically or as manually
as you choose, determining relationships based on foreign keys or letting you
define the join conditions explicitly, to bridge the gap between database and
domain.

This package contains version 1.4 of SQLAlchemy for software which is not
compatible with SQLAlchemy version 2.

%package -n python3-sqlalchemy1.4
Summary:        %{summary}
Conflicts:      python3-sqlalchemy >= 2
Provides:       python3-sqlalchemy = %{?epoch:%{epoch}:}%{version}-%{release}

%description -n python3-sqlalchemy1.4
SQLAlchemy is an Object Relational Mapper (ORM) that provides a flexible,
high-level interface to SQL databases.  Database and domain concepts are
decoupled, allowing both sides maximum flexibility and power. SQLAlchemy
provides a powerful mapping layer that can work as automatically or as manually
as you choose, determining relationships based on foreign keys or letting you
define the join conditions explicitly, to bridge the gap between database and
domain.

This package contains version 1.4 of SQLAlchemy for software which is not
compatible with SQLAlchemy version 2.

# Subpackages to ensure dependencies enabling extra functionality
%pyproject_extras_subpkg -n python3-sqlalchemy1.4 %python_pkg_extras

%package doc
Summary:        Documentation for SQLAlchemy 1.4
BuildArch:      noarch

%description doc
Documentation for SQLAlchemy 1.4.


%generate_buildrequires
%pyproject_buildrequires


%prep
%autosetup -n %{canonicalname}-%{srcversion} -p1

%build
export REQUIRE_SQLALCHEMY_CEXT=1
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{canonicalname}
# Work around poetry not listing license files as such in package metadata.
sed -i -e 's|^\(.*/LICENSE\)|%%license \1|g' %{pyproject_files}

install -d %{buildroot}%{_pkgdocdir}
cp -a doc examples %{buildroot}%{_pkgdocdir}/
# remove unnecessary scripts for building documentation
rm -rf %{buildroot}%{_pkgdocdir}/doc/build
find %{buildroot}%{_pkgdocdir} | while read long; do
    short="${long#%{buildroot}}"
    if [ -d "$long" ]; then
        echo "%%doc %%dir $short"
    else
        if [ "$short" != "${short/copyright/}" ]; then
            echo "%%license $short"
        else
            echo "%%doc $short"
        fi
    fi
done > doc-files.txt


%check
# Skip memory profiling, which takes a long time, does not run by default in
# the upstream tox config, and makes little sense to run downstream.
k="${k-}${k+ and }not aaa_profiling"

%pytest test -k "${k-}" \
%if %{with xdist}
--numprocesses=auto
%endif


%files doc -f doc-files.txt

%files -n python3-sqlalchemy1.4 -f %{pyproject_files}
%doc README.rst

%changelog
## START: Generated by rpmautospec
* Fri Sep 06 2024 Nils Philippsen <nils@tiptoe.de> - 1.4.54-1
- Update to 1.4.54

* Fri Aug 02 2024 Nils Philippsen <nils@tiptoe.de> - 1.4.53-1
- Update to 1.4.53

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.52-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sun Jun 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4.52-6
- Skip memory profiling in %%check

* Sun Jun 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4.52-5
- Ensure the package doesn’t build without the C extension

* Sun Jun 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4.52-4
- Backport serializer fixes for Python 3.13

* Sun Jun 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4.52-3
- Fix building the C extension on Python 3.13

* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 1.4.52-2
- Rebuilt for Python 3.13

* Mon Mar 04 2024 Nils Philippsen <nils@tiptoe.de> - 1.4.52-1
- Update to 1.4.52

* Thu Feb 01 2024 Nils Philippsen <nils@tiptoe.de> - 1.4.51-1
- Initial import of the package
## END: Generated by rpmautospec