Blame python-databases.spec

5187759
%global forgeurl https://github.com/encode/databases
b95aad0
b95aad0
# When bootstrapping, break circular dependency on starlette in the tests.
b95aad0
%bcond_with bootstrap
b95aad0
5187759
Name:           python-databases
b95aad0
Summary:        Async database support for Python
070ab3e
Version:        0.5.2
5b89981
Release:        %autorelease
b95aad0
b95aad0
License:        BSD
5187759
URL:            https://www.encode.io/databases/
5187759
Source0:        %{forgeurl}/archive/%{version}/databases-%{version}.tar.gz
b95aad0
b95aad0
BuildArch:      noarch
b95aad0
b95aad0
BuildRequires:  python3-devel
b95aad0
b95aad0
# Additional BR’s for testing, from requirements.txt only (therefore not
b95aad0
# generated):
b95aad0
# “Sync database drivers for standard tooling around
b95aad0
# setup/teardown/migrations.”
b95aad0
BuildRequires:  python3dist(psycopg2)
b95aad0
BuildRequires:  python3dist(pymysql)
b95aad0
b95aad0
# “Testing”
b95aad0
# We have excluded formatters, linters, and analysis tools: autoflake, black,
b95aad0
# codecov, isort, mypy
b95aad0
BuildRequires:  python3dist(pytest)
b95aad0
BuildRequires:  python3dist(pytest-cov)
b95aad0
%if %{without bootstrap}
b95aad0
BuildRequires:  python3dist(starlette)
b95aad0
# Used only as a soft dependency of starlette
b95aad0
BuildRequires:  python3dist(requests)
b95aad0
%endif
b95aad0
2b41dae
Obsoletes:      python-databases-doc < 0.5.2-4
2b41dae
b95aad0
%global common_description %{expand:
b95aad0
Databases gives you simple asyncio support for a range of databases.
b95aad0
b95aad0
It allows you to make queries using the powerful SQLAlchemy Core expression
b95aad0
language, and provides support for PostgreSQL, MySQL, and SQLite.
b95aad0
b95aad0
Databases is suitable for integrating against any async Web framework, such as
b95aad0
Starlette, Sanic, Responder, Quart, aiohttp, Tornado, or FastAPI.
b95aad0
b95aad0
Documentation: https://www.encode.io/databases/
b95aad0
b95aad0
Community: https://discuss.encode.io/c/databases}
b95aad0
b95aad0
%description %{common_description}
b95aad0
b95aad0
4bea3d7
# README.md:
4bea3d7
#   Note that if you are using any synchronous SQLAlchemy functions such as
4bea3d7
#   `engine.create_all()` or [alembic][alembic] migrations then you still have
4bea3d7
#   to install a synchronous DB driver: [psycopg2][psycopg2] for PostgreSQL and
4bea3d7
#   [pymysql][pymysql] for MySQL.
4bea3d7
# Therefore we manually write out the extras metapackages for PostgreSQL and
4bea3d7
# MySQL so that we can add these drivers as Recommends. Use, e.g.:
4bea3d7
#   rpm -E '%%pyproject_extras_subpkg -n python3-databases postgresql …'
4bea3d7
# to see the proper macro expanson (but note that the absolute path to
4bea3d7
# %%{_pyproject_ghost_distinfo} must be fixed). We can still handle SQLite the
4bea3d7
# easy way.
5187759
%pyproject_extras_subpkg -n python3-databases sqlite
4bea3d7
4bea3d7
5187759
%package -n python3-databases+postgresql
5187759
Summary:        Metapackage for python3-databases: postgresql extras
4bea3d7
5187759
Requires:       python3-databases = %{version}-%{release}
4bea3d7
Recommends:     python3dist(psycopg2)
4bea3d7
5187759
%description -n python3-databases+postgresql
4bea3d7
This is a metapackage bringing in postgresql extras requires for
5187759
python3-databases.
4bea3d7
It makes sure the dependencies are installed.
4bea3d7
5187759
%files -n python3-databases+postgresql -f %{_pyproject_ghost_distinfo}
4bea3d7
4bea3d7
5187759
%package -n python3-databases+mysql
5187759
Summary: Metapackage for python3-databases: mysql extras
4bea3d7
Recommends:     python3dist(pymysql)
4bea3d7
5187759
Requires: python3-databases = %{version}-%{release}
4bea3d7
5187759
%description -n python3-databases+mysql
5187759
This is a metapackage bringing in mysql extras requires for python3-databases.
4bea3d7
It makes sure the dependencies are installed.
4bea3d7
5187759
%files -n python3-databases+mysql -f %{_pyproject_ghost_distinfo}
4bea3d7
4bea3d7
5187759
%package -n python3-databases+postgresql_aiopg
5187759
Summary: Metapackage for python3-databases: postgresql_aiopg extras
4bea3d7
5187759
Requires: python3-databases = %{version}-%{release}
4bea3d7
Recommends:     python3dist(psycopg2)
4bea3d7
5187759
%description -n python3-databases+postgresql_aiopg
4bea3d7
This is a metapackage bringing in postgresql_aiopg extras requires for
5187759
python3-databases.
4bea3d7
It makes sure the dependencies are installed.
4bea3d7
5187759
%files -n python3-databases+postgresql_aiopg -f %{_pyproject_ghost_distinfo}
b95aad0
b95aad0
5187759
%package -n     python3-databases
b95aad0
Summary:        %{summary}
b95aad0
5187759
%description -n python3-databases %{common_description}
b95aad0
b95aad0
b95aad0
%prep
5187759
%autosetup -n databases-%{version}
f53e42e
# The following is equivalent to the former patch file
f53e42e
# databases-0.4.3-wayward-license-file.patch, but the sed expression works
f53e42e
# regardless of whether databases-pr-299-40c41c2b.patch has affected nearby
f53e42e
# lines or not.
f53e42e
#
f53e42e
# Without this patch, the LICENSE.md file is installed under the prefix
f53e42e
# (generally, /usr/local or /usr), or when installed into a virtualenv, in the
f53e42e
# root of the virtualenv directory. Neither is correct.
f53e42e
#
f53e42e
# Upstream doesn’t want bug reports or PR’s in general
f53e42e
# (https://github.com/encode/.github/blob/
f53e42e
#  e018bb630a92efd4609c2b60955e9c4678cd6c11/CONTRIBUTING.md),
f53e42e
# so I raised the issue in the Gitter chat on 2021-04-26.
f53e42e
sed -i -r '/data_files=\[\("", \["LICENSE.md"\]\)\],/d' setup.py
b95aad0
b95aad0
4fa6fbc
%generate_buildrequires
4fa6fbc
%pyproject_buildrequires -x postgresql,mysql,sqlite,postgresql_aiopg
4fa6fbc
4fa6fbc
b95aad0
%build
b95aad0
%pyproject_wheel
b95aad0
b95aad0
b95aad0
%install
b95aad0
%pyproject_install
5187759
%pyproject_save_files databases
b95aad0
b95aad0
b95aad0
%check
b95aad0
%if %{with bootstrap}
b95aad0
rm tests/test_integration.py
b95aad0
%endif
b95aad0
b95aad0
# E   ModuleNotFoundError: No module named 'tests'
b95aad0
touch tests/__init__.py
b95aad0
b95aad0
# We can only run the tests with SQLite; other databases require a properly
b95aad0
# configured server, which we cannot in general provide as an unprivileged
b95aad0
# user. The following environment variable is a comma-separated list.
b95aad0
export TEST_DATABASE_URLS="sqlite:///testsuite"
b95aad0
b95aad0
%pytest
b95aad0
b95aad0
5187759
%files -n python3-databases -f %{pyproject_files}
b95aad0
%doc CHANGELOG.md
b95aad0
%doc README.md
b95aad0
b95aad0
b95aad0
%changelog
5b89981
%autochangelog