Blob Blame History Raw
%global forgeurl

# When bootstrapping, break circular dependency on starlette in the tests.
%bcond_with bootstrap

Name:           python-databases
Summary:        Async database support for Python
Version:        0.5.2
Release:        %autorelease

License:        BSD
Source0:        %{forgeurl}/archive/%{version}/databases-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel

# Additional BR’s for testing, from requirements.txt only (therefore not
# generated):
# “Sync database drivers for standard tooling around
# setup/teardown/migrations.”
BuildRequires:  python3dist(psycopg2)
BuildRequires:  python3dist(pymysql)

# “Testing”
# We have excluded formatters, linters, and analysis tools: autoflake, black,
# codecov, isort, mypy
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(pytest-cov)
%if %{without bootstrap}
BuildRequires:  python3dist(starlette)
# Used only as a soft dependency of starlette
BuildRequires:  python3dist(requests)

Obsoletes:      python-databases-doc < 0.5.2-4

%global common_description %{expand:
Databases gives you simple asyncio support for a range of databases.

It allows you to make queries using the powerful SQLAlchemy Core expression
language, and provides support for PostgreSQL, MySQL, and SQLite.

Databases is suitable for integrating against any async Web framework, such as
Starlette, Sanic, Responder, Quart, aiohttp, Tornado, or FastAPI.



%description %{common_description}

#   Note that if you are using any synchronous SQLAlchemy functions such as
#   `engine.create_all()` or [alembic][alembic] migrations then you still have
#   to install a synchronous DB driver: [psycopg2][psycopg2] for PostgreSQL and
#   [pymysql][pymysql] for MySQL.
# Therefore we manually write out the extras metapackages for PostgreSQL and
# MySQL so that we can add these drivers as Recommends. Use, e.g.:
#   rpm -E '%%pyproject_extras_subpkg -n python3-databases postgresql …'
# to see the proper macro expanson (but note that the absolute path to
# %%{_pyproject_ghost_distinfo} must be fixed). We can still handle SQLite the
# easy way.
%pyproject_extras_subpkg -n python3-databases sqlite

%package -n python3-databases+postgresql
Summary:        Metapackage for python3-databases: postgresql extras

Requires:       python3-databases = %{version}-%{release}
Recommends:     python3dist(psycopg2)

%description -n python3-databases+postgresql
This is a metapackage bringing in postgresql extras requires for
It makes sure the dependencies are installed.

%files -n python3-databases+postgresql -f %{_pyproject_ghost_distinfo}

%package -n python3-databases+mysql
Summary: Metapackage for python3-databases: mysql extras
Recommends:     python3dist(pymysql)

Requires: python3-databases = %{version}-%{release}

%description -n python3-databases+mysql
This is a metapackage bringing in mysql extras requires for python3-databases.
It makes sure the dependencies are installed.

%files -n python3-databases+mysql -f %{_pyproject_ghost_distinfo}

%package -n python3-databases+postgresql_aiopg
Summary: Metapackage for python3-databases: postgresql_aiopg extras

Requires: python3-databases = %{version}-%{release}
Recommends:     python3dist(psycopg2)

%description -n python3-databases+postgresql_aiopg
This is a metapackage bringing in postgresql_aiopg extras requires for
It makes sure the dependencies are installed.

%files -n python3-databases+postgresql_aiopg -f %{_pyproject_ghost_distinfo}

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

%description -n python3-databases %{common_description}

%autosetup -n databases-%{version}
# The following is equivalent to the former patch file
# databases-0.4.3-wayward-license-file.patch, but the sed expression works
# regardless of whether databases-pr-299-40c41c2b.patch has affected nearby
# lines or not.
# Without this patch, the file is installed under the prefix
# (generally, /usr/local or /usr), or when installed into a virtualenv, in the
# root of the virtualenv directory. Neither is correct.
# Upstream doesn’t want bug reports or PR’s in general
# (
#  e018bb630a92efd4609c2b60955e9c4678cd6c11/,
# so I raised the issue in the Gitter chat on 2021-04-26.
sed -i -r '/data_files=\[\("", \[""\]\)\],/d'

%pyproject_buildrequires -x postgresql,mysql,sqlite,postgresql_aiopg


%pyproject_save_files databases

%if %{with bootstrap}
rm tests/

# E   ModuleNotFoundError: No module named 'tests'
touch tests/

# We can only run the tests with SQLite; other databases require a properly
# configured server, which we cannot in general provide as an unprivileged
# user. The following environment variable is a comma-separated list.
export TEST_DATABASE_URLS="sqlite:///testsuite"


%files -n python3-databases -f %{pyproject_files}