## START: Set by rpmautospec ## (rpmautospec version 0.2.5) %define autorelease(e:s:pb:) %{?-p:0.}%{lua: release_number = 4; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{?dist} ## END: Set by rpmautospec # When bootstrapping, break circular dependency on starlette in the tests. %bcond_with bootstrap # MySQL tests require interacting with a temporary MySQL database. We are able # to do this, but leave a build conditional in case it breaks. %bcond_without mysql_tests Name: python-databases Summary: Async database support for Python Version: 0.5.5 Release: %autorelease License: BSD URL: https://www.encode.io/databases/ %global forgeurl https://github.com/encode/databases Source0: %{forgeurl}/archive/%{version}/databases-%{version}.tar.gz # This package contains no compiled code and should be inherently noarch, but # the asyncmy dependency for the mysql_asyncmy/mysql+asyncmy extra is # ExcludeArch on 32-bit platforms (RHBZ#2060899), which unfortunately means # this package as a whole must be archful in order to drop that extra on the # affected platforms. We can still make the binary RPMs noarch, except for the # affected extra metapackage. %global debug_package %{nil} %ifnarch %{ix86} %{arm32} %global with_asyncmy 1 %endif 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) %endif %if %{with mysql_tests} BuildRequires: mariadb-server %endif %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. Documentation: https://www.encode.io/databases/ Community: https://discuss.encode.io/c/databases} %description %{common_description} # README.md: # 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. We can still handle # SQLite the easy way—but we don’t, because it would inherit the archfulness of # the base package, and we want it to be noarch. %package -n python3-databases+sqlite Summary: Metapackage for python3-databases: sqlite extras BuildArch: noarch Requires: python3-databases = %{version}-%{release} %description -n python3-databases+sqlite This is a metapackage bringing in sqlite extras requires for python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+sqlite %ghost %{python3_sitelib}/*.dist-info %package -n python3-databases+postgresql Summary: Metapackage for python3-databases: postgresql extras BuildArch: noarch Requires: python3-databases = %{version}-%{release} Recommends: python3dist(psycopg2) %description -n python3-databases+postgresql This is a metapackage bringing in postgresql extras requires for python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+postgresql %ghost %{python3_sitelib}/*.dist-info %if 0%{?with_asyncmy} %package -n python3-databases+mysql_asyncmy Summary: Metapackage for python3-databases: mysql_asyncmy extras Recommends: python3dist(pymysql) Requires: python3-databases = %{version}-%{release} # pymysql tests only work with pymysql<=1.0 # https://github.com/encode/databases/issues/330 Obsoletes: python3-databases+mysql < 0.5.5-1 %description -n python3-databases+mysql_asyncmy This is a metapackage bringing in mysql_asyncmy extras requires for python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+mysql_asyncmy %ghost %{python3_sitelib}/*.dist-info %endif %package -n python3-databases+postgresql_aiopg Summary: Metapackage for python3-databases: postgresql_aiopg extras BuildArch: noarch 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 python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+postgresql_aiopg %ghost %{python3_sitelib}/*.dist-info %package -n python3-databases Summary: %{summary} BuildArch: noarch Obsoletes: python-databases-doc < 0.5.2-4 %description -n python3-databases %{common_description} %prep %autosetup -n databases-%{version} -p1 %if !0%{?with_asyncmy} sed -r -i \ -e 's/^([[:blank:]]*)(.*import AsyncMyBackend.*)$/# \1\2\n\1pass/' \ -e 's/^def test_asyncmy_.*$/@pytest.mark.skip("asyncmy does not support 32-bit")\n&/' \ tests/test_connection_options.py %endif %generate_buildrequires %pyproject_buildrequires -x postgresql,%{?with_asyncmy:mysql_asyncmy,}sqlite,postgresql_aiopg %build %pyproject_wheel %install %pyproject_install %pyproject_save_files databases %check %if %{with bootstrap} rm tests/test_integration.py %endif # E ModuleNotFoundError: No module named 'tests' touch tests/__init__.py # 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, sqlite+aiosqlite:///testsuite" %if 0%{?with_asyncmy} # Currently, asyncmy is the only MySQL backend supported on Python 3.10+, so # there is no need to start a MySQL/MariaDB daemon on architectures where it is # not available. %if %{with mysql_tests} # Based on rubygem-mysql2 packaging; see also python-asyncmy # Use a randomized port in case the standard mysqld port 3306 is occupied, and # to account for multiple simultaneous builds on the same host. # https://src.fedoraproject.org/rpms/rubygem-pg/pull-request/3 MYSQL_PORT="$((13306 + ${RANDOM} % 1000))" MYSQL_USER="$(whoami)" MYSQL_DATA_DIR="${PWD}/data" MYSQL_SOCKET="${PWD}/mysql.sock" MYSQL_LOG="${PWD}/mysql.log" MYSQL_PID_FILE="${PWD}/mysql.pid" mkdir "${MYSQL_DATA_DIR}" mysql_install_db --datadir="${MYSQL_DATA_DIR}" --log-error="${MYSQL_LOG}" %{_libexecdir}/mysqld --port="${MYSQL_PORT}" --ssl \ --datadir="${MYSQL_DATA_DIR}" --log-error="${MYSQL_LOG}" \ --socket="${MYSQL_SOCKET}" --pid-file="${MYSQL_PID_FILE}" & : echo "Waiting for server… ${i}" 1>&2 TIMEOUT=30 while ! grep -q 'ready for connections.' "${MYSQL_LOG}" do sleep 1 TIMEOUT=$((TIMEOUT - 1)) if [[ "${TIMEOUT}" = '0' ]] then echo 'Timed out' 1>&2 exit 1 fi done echo 'Ready' 1>&2 trap "kill $(cat "${MYSQL_PID_FILE}")" INT TERM EXIT # See https://github.com/brianmario/mysql2/blob/master/.travis_setup.sh mysql -u "${MYSQL_USER}" -S "${MYSQL_SOCKET}" -P "${MYSQL_PORT}" \ -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';" mysql -u 'root' --password='123456' \ --protocol='TCP' -h 'localhost' -P "${MYSQL_PORT}" \ -e 'CREATE DATABASE testsuite;' # Since we the “mysql” extra/backend is not supported on Python 3.10, we should # not attempt to test mysql:// URLs, only mysql+…//. for url in \ "mysql+asyncmy://root:123456@localhost:${MYSQL_PORT}/testsuite" do export TEST_DATABASE_URLS="${TEST_DATABASE_URLS}, ${url}" done %endif %endif %pytest --verbose # Since we can’t test all backends, at least do an import “smoke test,” but # note that the “mysql” extra/backend is not supported, so we must exclude it. %pyproject_check_import -e 'databases.backends.mysql' %{?!with_asyncmy:-e 'databases.backends.asyncmy'} %files -n python3-databases -f %{pyproject_files} %doc CHANGELOG.md %doc README.md %changelog * Tue Apr 12 2022 Benjamin A. Beasley 0.5.5-4 - Stop using “private” macro %%_pyproject_ghost_distinfo * Fri Mar 04 2022 Benjamin A. Beasley 0.5.5-3 - Work around asyncmy 32-bit ExcludeArch * Fri Mar 04 2022 Benjamin A. Beasley 0.5.5-2 - Do not patch in sqlalchemy[asyncio] extra dependency * Thu Mar 03 2022 Benjamin A. Beasley 0.5.5-1 - Update to 0.5.5 (close RHBZ#2040765) * Fri Jan 21 2022 Fedora Release Engineering 0.5.3-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild * Sun Oct 10 2021 Benjamin A. Beasley 0.5.3-2 - Work around RHBZ#2012590: depend on greenlet * Sun Oct 10 2021 Benjamin A. Beasley 0.5.3-1 - Update to 0.5.3 (close RHBZ#2012577) * Fri Oct 01 2021 Benjamin A. Beasley 0.5.2-4 - Drop the documentation subpackage entirely. * Mon Sep 13 2021 Benjamin A. Beasley 0.5.2-3 - Let pyproject-rpm-macros handle the license file * Sun Sep 12 2021 Benjamin A. Beasley 0.5.2-2 - Drop BR on pyproject-rpm-macros, now implied by python3-devel * Fri Sep 10 2021 Benjamin A. Beasley 0.5.2-1 - Update to 0.5.2 (close RHBZ#2003094) * Wed Sep 08 2021 Benjamin A. Beasley 0.5.1-2 - Reduce macro indirection in spec file * Thu Sep 02 2021 Benjamin A. Beasley 0.5.1-1 - Update to 0.5.1 (close RHBZ#2000532) * Fri Aug 27 2021 Benjamin A. Beasley 0.5.0-1 - Update to 0.5.0 (close RHBZ#1998268) * Wed Aug 11 2021 Benjamin A. Beasley 0.4.3-10 - Add a build conditional for mkdocs; disable it since it is orphaned * Tue Jul 27 2021 Benjamin A. Beasley 0.4.3-9 - Move %generate_buildrequires after %prep to make the spec file easier to follow * Tue Jun 08 2021 Python Maint - 0.4.3-5 - Rebuilt for Python 3.10 * Fri Jun 04 2021 Python Maint - 0.4.3-4 - Bootstrap for Python 3.10 * Fri May 28 2021 Benjamin A. Beasley - 0.4.3-3 - Build documentation without the mkdocs-material theme * Fri May 14 2021 Benjamin A. Beasley - 0.4.3-2 - Patch in SQLAlchemy 1.4 support from upstream PR#299 on Fedora 35 - Reimplement databases-0.4.3-wayward-license-file.patch using sed in %%prep * Tue Apr 27 2021 Benjamin A. Beasley - 0.4.3-1 - Initial package